# HG changeset patch # User Christian Humer # Date 1395063059 -3600 # Node ID b1dded9c748a2572b18ed86b5f4cc77f8f6e6f21 # Parent 6681b9eb3f4cebbfcb60715f533429317591c356# Parent 82e4fe6fa52594024a30f0f288cff16de6b13571 Merge. diff -r 6681b9eb3f4c -r b1dded9c748a .hgtags --- a/.hgtags Mon Mar 17 14:29:45 2014 +0100 +++ b/.hgtags Mon Mar 17 14:30:59 2014 +0100 @@ -404,3 +404,7 @@ fca262db9c4309f99d2f5542ab0780e45c2f1578 jdk8-b120 41f4cad94c581034d4c427d2aaabcc20f26342d0 hs25-b63 b124e22eb772806c13d942cc110de38da0108147 graal-0.1 +ce2d7e46f3c7e41241f3b407705a4071323a11ab jdk9-b00 +050a626a88951140df874f7b163e304d07b6c296 jdk9-b01 +b188446de75bda5fc52d102cddf242c3ef5ecbdf jdk9-b02 +b2fee789d23f3cdabb3db4e51af43038e5692d3a jdk9-b03 diff -r 6681b9eb3f4c -r b1dded9c748a CHANGELOG.md --- a/CHANGELOG.md Mon Mar 17 14:29:45 2014 +0100 +++ b/CHANGELOG.md Mon Mar 17 14:30:59 2014 +0100 @@ -3,7 +3,8 @@ ## `tip` ### Graal * New methods for querying memory usage of individual objects and object graphs in Graal API (MetaAccessProvider#getMemorySize, MetaUtil#getMemorySizeRecursive). -* ... +* New (tested) invariant that equality comparisons for JavaType/JavaMethod/JavaField values use .equals() instead of '=='. +* Made graph caching compilation-local. ### Truffle * ... diff -r 6681b9eb3f4c -r b1dded9c748a THIRD_PARTY_README --- a/THIRD_PARTY_README Mon Mar 17 14:29:45 2014 +0100 +++ b/THIRD_PARTY_README Mon Mar 17 14:30:59 2014 +0100 @@ -2,11 +2,12 @@ ----------------------------- %% This notice is provided with respect to ASM Bytecode Manipulation -Framework v3.1, which is included with JRE 7, JDK 7, and OpenJDK 7. +Framework v5.0, which may be included with JRE 8, and JDK 8, and +OpenJDK 8. --- begin of LICENSE --- -Copyright (c) 2000-2005 INRIA, France Telecom +Copyright (c) 2000-2011 France Télécom All rights reserved. Redistribution and use in source and binary forms, with or without @@ -40,8 +41,41 @@ -------------------------------------------------------------------------------- -%% This notice is provided with respect to CodeViewer 1.0, which is included -with JDK 7. +%% This notice is provided with respect to BSDiff v4.3, which may be +included with JRE 8, JDK 8, and OpenJDK 8. + +--- begin of LICENSE --- + +Copyright 2003-2005 Colin Percival +All rights reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted providing that the following conditions +are met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + +%% This notice is provided with respect to CodeViewer 1.0, which may be +included with JDK 8. --- begin of LICENSE --- @@ -81,8 +115,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Cryptix AES 3.2.0, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to Cryptix AES 3.2.0, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -121,7 +155,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to CUP Parser Generator for -Java 0.10k, which is included with JRE 7, JDK 7, and OpenJDK 7. +Java 0.10k, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -148,7 +182,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to Document Object Model (DOM) Level 2 -& 3, which is included with JRE 7, JDK 7, and OpenJDK 7. +& 3, which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -212,19 +246,52 @@ ------------------------------------------------------------------------------- +%% This notice is provided with respect to Dynalink v0.5, which may be +included with JRE 8, JDK 8, and OpenJDK 8. + +--- begin of LICENSE --- + +Copyright (c) 2009-2013, Attila Szegedi + +All rights reserved.Redistribution and use in source and binary forms, with or +without modification, are permitted provided that the following conditions are +met:* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. * Redistributions in +binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or other +materials provided with the distribution. * Neither the name of Attila +Szegedi nor the names of its contributors may be used to endorse or promote +products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + %% This notice is provided with respect to Elliptic Curve Cryptography, which -is included with JRE 7, JDK 7, and OpenJDK 7. +may be included with JRE 8, JDK 8, and OpenJDK 8. You are receiving a copy of the Elliptic Curve Cryptography library in source -form with the JDK 7 source distribution and object code in the JRE 7 & JDK 7 -runtime. - -The terms of the Oracle license do NOT apply to the Elliptic Curve -Cryptography library program; it is licensed under the following license, -separately from the Oracle programs you receive. If you do not wish to install -this program, you may delete the library named libsunec.so (on Solaris and -Linux systems) or sunec.dll (on Windows systems) from the JRE bin directory -reserved for native libraries. +form with the JDK 8 and OpenJDK 8 source distributions, and as object code in +the JRE 8 & JDK 8 runtimes. + +In the case of the JRE 8 & JDK 8 runtimes, the terms of the Oracle license do +NOT apply to the Elliptic Curve Cryptography library; it is licensed under the +following license, separately from Oracle's JDK & JRE. If you do not wish to +install the Elliptic Curve Cryptography library, you may delete the library +named libsunec.so (on Solaris and Linux systems) or sunec.dll (on Windows +systems) from the JRE bin directory reserved for native libraries. + --- begin of LICENSE --- @@ -735,13 +802,138 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to FontConfig 2.5, which is -included with JRE 7, JDK 7, and OpenJDK 7 source distributions on +%% This notice is provided with respect to ECMAScript Language +Specification ECMA-262 Edition 5.1 which may be included with +JRE 8, JDK 8, and OpenJDK 8. + +--- begin of LICENSE --- + +Copyright notice +Copyright © 2011 Ecma International +Ecma International +Rue du Rhone 114 +CH-1204 Geneva +Tel: +41 22 849 6000 +Fax: +41 22 849 6001 +Web: http://www.ecma-international.org + +This document and possible translations of it may be copied and furnished to +others, and derivative works that comment on or otherwise explain it or assist +in its implementation may be prepared, copied, published, and distributed, in +whole or in part, without restriction of any kind, provided that the above +copyright notice and this section are included on all such copies and derivative +works. However, this document itself may not be modified in any way, including +by removing the copyright notice or references to Ecma International, except as +needed for the purpose of developing any document or deliverable produced by +Ecma International (in which case the rules applied to copyrights must be +followed) or as required to translate it into languages other than English. The +limited permissions granted above are perpetual and will not be revoked by Ecma +International or its successors or assigns. This document and the information +contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY +WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE." Software License + +All Software contained in this document ("Software)" is protected by copyright +and is being made available under the "BSD License", included below. This +Software may be subject to third party rights (rights from parties other than +Ecma International), including patent rights, and no licenses under such third +party rights are granted under this license even if the third party concerned is +a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS +AVAILABLE AT http://www.ecma-international.org/memento/codeofconduct.htm FOR +INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO +IMPLEMENT ECMA INTERNATIONAL STANDARDS*. Redistribution and use in source and +binary forms, with or without modification, are permitted provided that the +following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the authors nor Ecma International may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +OF SUCH DAMAGE. +--- end of LICENSE --- + +%% This notice is provided with respect to Dynalink library which is included +with the Nashorn technology. + +--- begin of LICENSE --- +Copyright (c) 2009-2013, Attila Szegedi + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--- end of LICENSE --- + +%% This notice is provided with respect to Joni library which is included +with the Nashorn technology. + +--- begin of LICENSE --- +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + +%% This notice is provided with respect to FontConfig 2.5, which may be +included with JRE 8, JDK 8, and OpenJDK 8 source distributions on Linux and Solaris. --- begin of LICENSE --- -Copyright ¬© 2001,2003 Keith Packard +Copyright © 2001,2003 Keith Packard Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the @@ -765,7 +957,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to IAIK PKCS#11 Wrapper, -which is included with JRE 7, JDK 7, and OpenJDK 7. +which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -816,7 +1008,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to ICU4C 4.0.1 and ICU4J 4.4, which -is included with JRE 7, JDK 7, and OpenJDK 7. +may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -852,8 +1044,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to IJG JPEG 6b, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to IJG JPEG 6b, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -891,8 +1083,35 @@ -------------------------------------------------------------------------------- -%% This notice is provided with respect to JOpt-Simple v3.0, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to Joni v1.1.9, which may be +included with JRE 8, JDK 8, and OpenJDK 8. + +--- begin of LICENSE --- + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + +%% This notice is provided with respect to JOpt-Simple v3.0, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -921,8 +1140,39 @@ -------------------------------------------------------------------------------- +%% This notice is provided with respect to JSON, which may be included +with JRE 8 & JDK 8. + +--- begin of LICENSE --- + +Copyright (c) 2002 JSON.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + %% This notice is provided with respect to Kerberos functionality, which -which is included with JRE 7, JDK 7, and OpenJDK 7. +which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -934,7 +1184,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to Kerberos functionality from -FundsXpress, INC., which is included with JRE 7, JDK 7, and OpenJDK 7. +FundsXpress, INC., which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -967,8 +1217,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Kronos OpenGL headers, which is -included with JDK 7 and OpenJDK 7 source distributions. +%% This notice is provided with respect to Kronos OpenGL headers, which may be +included with JDK 8 and OpenJDK 8 source distributions. --- begin of LICENSE --- @@ -1000,8 +1250,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to libpng 1.2.18, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to libpng 1.5.4, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1014,8 +1264,10 @@ If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are -Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are +This code is released under the libpng license. + +libpng versions 1.2.6, August 15, 2004, through 1.5.4, July 7, 2011, are +Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -1112,14 +1364,14 @@ Glenn Randers-Pehrson glennrp at users.sourceforge.net -May 15, 2007 +July 7, 2011 --- end of LICENSE --- ------------------------------------------------------------------------------- -%% This notice is provided with respect to libungif 4.1.3, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to libungif 4.1.3, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1147,8 +1399,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Little CMS 2.0, which is -included with OpenJDK 7. +%% This notice is provided with respect to Little CMS 2.4, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1183,7 +1435,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to Mesa 3D Graphics Library v4.1, -which is included with JRE 7, JDK 7, and OpenJDK 7 source distributions. +which may be included with JRE 8, JDK 8, and OpenJDK 8 source distributions. --- begin of LICENSE --- @@ -1213,8 +1465,402 @@ ------------------------------------------------------------------------------- +%% This notice is provided with respect to Mozilla Network Security +Services (NSS), which is supplied with the JDK test suite in the OpenJDK +source code repository. It is licensed under Mozilla Public License (MPL), +version 2.0. + +The NSS libraries are supplied in executable form, built from unmodified +NSS source code labeled with the "NSS_3.13.1_RTM" release tag. + +The NSS source code is available in the OpenJDK source code repository at: + jdk/test/sun/security/pkcs11/nss/src + +The NSS libraries are available in the OpenJDK source code repository at: + jdk/test/sun/security/pkcs11/nss/lib + +--- begin of LICENSE --- + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + %% This notice is provided with respect to PC/SC Lite for Suse Linux v.1.1.1, -which is included with JRE 7, JDK 7, and OpenJDK 7 on Linux and Solaris. +which may be included with JRE 8, JDK 8, and OpenJDK 8 on Linux and Solaris. --- begin of LICENSE --- @@ -1257,8 +1903,30 @@ ------------------------------------------------------------------------------- +%% This notice is provided with respect to PorterStemmer v4, which may be +included with JRE 8, JDK 8, and OpenJDK 8. + +--- begin of LICENSE --- + +See: http://tartarus.org/~martin/PorterStemmer + +The software is completely free for any purpose, unless notes at the head of +the program text indicates otherwise (which is rare). In any case, the notes +about licensing are never more restrictive than the BSD License. + +In every case where the software is not written by me (Martin Porter), this +licensing arrangement has been endorsed by the contributor, and it is +therefore unnecessary to ask the contributor again to confirm it. + +I have not asked any contributors (or their employers, if they have them) for +proofs that they have the right to distribute their software in this way. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + %% This notice is provided with respect to Relax NG Object/Parser v.20050510, -which is included with JRE 7, JDK 7, and OpenJDK 7. +which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1285,8 +1953,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to RelaxNGCC v1.12, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to RelaxNGCC v1.12, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1335,487 +2003,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Mozilla Rhino v1.7R3, which -is included with JRE 7, JDK 7, and OpenJDK 7 - ---- begin of LICENSE --- - - MOZILLA PUBLIC LICENSE - Version 1.1 - - --------------- - -1. Definitions. - - 1.0.1. "Commercial Use" means distribution or otherwise making the - Covered Code available to a third party. - - 1.1. "Contributor" means each entity that creates or contributes to - the creation of Modifications. - - 1.2. "Contributor Version" means the combination of the Original - Code, prior Modifications used by a Contributor, and the Modifications - made by that particular Contributor. - - 1.3. "Covered Code" means the Original Code or Modifications or the - combination of the Original Code and Modifications, in each case - including portions thereof. - - 1.4. "Electronic Distribution Mechanism" means a mechanism generally - accepted in the software development community for the electronic - transfer of data. - - 1.5. "Executable" means Covered Code in any form other than Source - Code. - - 1.6. "Initial Developer" means the individual or entity identified - as the Initial Developer in the Source Code notice required by Exhibit - A. - - 1.7. "Larger Work" means a work which combines Covered Code or - portions thereof with code not governed by the terms of this License. - - 1.8. "License" means this document. - - 1.8.1. "Licensable" means having the right to grant, to the maximum - extent possible, whether at the time of the initial grant or - subsequently acquired, any and all of the rights conveyed herein. - - 1.9. "Modifications" means any addition to or deletion from the - substance or structure of either the Original Code or any previous - Modifications. When Covered Code is released as a series of files, a - Modification is: - A. Any addition to or deletion from the contents of a file - containing Original Code or previous Modifications. - - B. Any new file that contains any part of the Original Code or - previous Modifications. - - 1.10. "Original Code" means Source Code of computer software code - which is described in the Source Code notice required by Exhibit A as - Original Code, and which, at the time of its release under this - License is not already Covered Code governed by this License. - - 1.10.1. "Patent Claims" means any patent claim(s), now owned or - hereafter acquired, including without limitation, method, process, - and apparatus claims, in any patent Licensable by grantor. - - 1.11. "Source Code" means the preferred form of the Covered Code for - making modifications to it, including all modules it contains, plus - any associated interface definition files, scripts used to control - compilation and installation of an Executable, or source code - differential comparisons against either the Original Code or another - well known, available Covered Code of the Contributor's choice. The - Source Code can be in a compressed or archival form, provided the - appropriate decompression or de-archiving software is widely available - for no charge. - - 1.12. "You" (or "Your") means an individual or a legal entity - exercising rights under, and complying with all of the terms of, this - License or a future version of this License issued under Section 6.1. - For legal entities, "You" includes any entity which controls, is - controlled by, or is under common control with You. For purposes of - this definition, "control" means (a) the power, direct or indirect, - to cause the direction or management of such entity, whether by - contract or otherwise, or (b) ownership of more than fifty percent - (50%) of the outstanding shares or beneficial ownership of such - entity. - -2. Source Code License. - - 2.1. The Initial Developer Grant. - The Initial Developer hereby grants You a world-wide, royalty-free, - non-exclusive license, subject to third party intellectual property - claims: - (a) under intellectual property rights (other than patent or - trademark) Licensable by Initial Developer to use, reproduce, - modify, display, perform, sublicense and distribute the Original - Code (or portions thereof) with or without Modifications, and/or - as part of a Larger Work; and - - (b) under Patents Claims infringed by the making, using or - selling of Original Code, to make, have made, use, practice, - sell, and offer for sale, and/or otherwise dispose of the - Original Code (or portions thereof). - - (c) the licenses granted in this Section 2.1(a) and (b) are - effective on the date Initial Developer first distributes - Original Code under the terms of this License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is - granted: 1) for code that You delete from the Original Code; 2) - separate from the Original Code; or 3) for infringements caused - by: i) the modification of the Original Code or ii) the - combination of the Original Code with other software or devices. - - 2.2. Contributor Grant. - Subject to third party intellectual property claims, each Contributor - hereby grants You a world-wide, royalty-free, non-exclusive license - - (a) under intellectual property rights (other than patent or - trademark) Licensable by Contributor, to use, reproduce, modify, - display, perform, sublicense and distribute the Modifications - created by such Contributor (or portions thereof) either on an - unmodified basis, with other Modifications, as Covered Code - and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using, or - selling of Modifications made by that Contributor either alone - and/or in combination with its Contributor Version (or portions - of such combination), to make, use, sell, offer for sale, have - made, and/or otherwise dispose of: 1) Modifications made by that - Contributor (or portions thereof); and 2) the combination of - Modifications made by that Contributor with its Contributor - Version (or portions of such combination). - - (c) the licenses granted in Sections 2.2(a) and 2.2(b) are - effective on the date Contributor first makes Commercial Use of - the Covered Code. - - (d) Notwithstanding Section 2.2(b) above, no patent license is - granted: 1) for any code that Contributor has deleted from the - Contributor Version; 2) separate from the Contributor Version; - 3) for infringements caused by: i) third party modifications of - Contributor Version or ii) the combination of Modifications made - by that Contributor with other software (except as part of the - Contributor Version) or other devices; or 4) under Patent Claims - infringed by Covered Code in the absence of Modifications made by - that Contributor. - -3. Distribution Obligations. - - 3.1. Application of License. - The Modifications which You create or to which You contribute are - governed by the terms of this License, including without limitation - Section 2.2. The Source Code version of Covered Code may be - distributed only under the terms of this License or a future version - of this License released under Section 6.1, and You must include a - copy of this License with every copy of the Source Code You - distribute. You may not offer or impose any terms on any Source Code - version that alters or restricts the applicable version of this - License or the recipients' rights hereunder. However, You may include - an additional document offering the additional rights described in - Section 3.5. - - 3.2. Availability of Source Code. - Any Modification which You create or to which You contribute must be - made available in Source Code form under the terms of this License - either on the same media as an Executable version or via an accepted - Electronic Distribution Mechanism to anyone to whom you made an - Executable version available; and if made available via Electronic - Distribution Mechanism, must remain available for at least twelve (12) - months after the date it initially became available, or at least six - (6) months after a subsequent version of that particular Modification - has been made available to such recipients. You are responsible for - ensuring that the Source Code version remains available even if the - Electronic Distribution Mechanism is maintained by a third party. - - 3.3. Description of Modifications. - You must cause all Covered Code to which You contribute to contain a - file documenting the changes You made to create that Covered Code and - the date of any change. You must include a prominent statement that - the Modification is derived, directly or indirectly, from Original - Code provided by the Initial Developer and including the name of the - Initial Developer in (a) the Source Code, and (b) in any notice in an - Executable version or related documentation in which You describe the - origin or ownership of the Covered Code. - - 3.4. Intellectual Property Matters - (a) Third Party Claims. - If Contributor has knowledge that a license under a third party's - intellectual property rights is required to exercise the rights - granted by such Contributor under Sections 2.1 or 2.2, - Contributor must include a text file with the Source Code - distribution titled "LEGAL" which describes the claim and the - party making the claim in sufficient detail that a recipient will - know whom to contact. If Contributor obtains such knowledge after - the Modification is made available as described in Section 3.2, - Contributor shall promptly modify the LEGAL file in all copies - Contributor makes available thereafter and shall take other steps - (such as notifying appropriate mailing lists or newsgroups) - reasonably calculated to inform those who received the Covered - Code that new knowledge has been obtained. - - (b) Contributor APIs. - If Contributor's Modifications include an application programming - interface and Contributor has knowledge of patent licenses which - are reasonably necessary to implement that API, Contributor must - also include this information in the LEGAL file. - - (c) Representations. - Contributor represents that, except as disclosed pursuant to - Section 3.4(a) above, Contributor believes that Contributor's - Modifications are Contributor's original creation(s) and/or - Contributor has sufficient rights to grant the rights conveyed by - this License. - - 3.5. Required Notices. - You must duplicate the notice in Exhibit A in each file of the Source - Code. If it is not possible to put such notice in a particular Source - Code file due to its structure, then You must include such notice in a - location (such as a relevant directory) where a user would be likely - to look for such a notice. If You created one or more Modification(s) - You may add your name as a Contributor to the notice described in - Exhibit A. You must also duplicate this License in any documentation - for the Source Code where You describe recipients' rights or ownership - rights relating to Covered Code. You may choose to offer, and to - charge a fee for, warranty, support, indemnity or liability - obligations to one or more recipients of Covered Code. However, You - may do so only on Your own behalf, and not on behalf of the Initial - Developer or any Contributor. You must make it absolutely clear than - any such warranty, support, indemnity or liability obligation is - offered by You alone, and You hereby agree to indemnify the Initial - Developer and every Contributor for any liability incurred by the - Initial Developer or such Contributor as a result of warranty, - support, indemnity or liability terms You offer. - - 3.6. Distribution of Executable Versions. - You may distribute Covered Code in Executable form only if the - requirements of Section 3.1-3.5 have been met for that Covered Code, - and if You include a notice stating that the Source Code version of - the Covered Code is available under the terms of this License, - including a description of how and where You have fulfilled the - obligations of Section 3.2. The notice must be conspicuously included - in any notice in an Executable version, related documentation or - collateral in which You describe recipients' rights relating to the - Covered Code. You may distribute the Executable version of Covered - Code or ownership rights under a license of Your choice, which may - contain terms different from this License, provided that You are in - compliance with the terms of this License and that the license for the - Executable version does not attempt to limit or alter the recipient's - rights in the Source Code version from the rights set forth in this - License. If You distribute the Executable version under a different - license You must make it absolutely clear that any terms which differ - from this License are offered by You alone, not by the Initial - Developer or any Contributor. You hereby agree to indemnify the - Initial Developer and every Contributor for any liability incurred by - the Initial Developer or such Contributor as a result of any such - terms You offer. - - 3.7. Larger Works. - You may create a Larger Work by combining Covered Code with other code - not governed by the terms of this License and distribute the Larger - Work as a single product. In such a case, You must make sure the - requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Code due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description - must be included in the LEGAL file described in Section 3.4 and must - be included with all distributions of the Source Code. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Application of this License. - - This License applies to code to which the Initial Developer has - attached the notice in Exhibit A and to related Covered Code. - -6. Versions of the License. - - 6.1. New Versions. - Netscape Communications Corporation ("Netscape") may publish revised - and/or new versions of the License from time to time. Each version - will be given a distinguishing version number. - - 6.2. Effect of New Versions. - Once Covered Code has been published under a particular version of the - License, You may always continue to use it under the terms of that - version. You may also choose to use such Covered Code under the terms - of any subsequent version of the License published by Netscape. No one - other than Netscape has the right to modify the terms applicable to - Covered Code created under this License. - - 6.3. Derivative Works. - If You create or use a modified version of this License (which you may - only do in order to apply it to code which is not already Covered Code - governed by this License), You must (a) rename Your license so that - the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", - "MPL", "NPL" or any confusingly similar phrase do not appear in your - license (except to note that your license differs from this License) - and (b) otherwise make it clear that Your version of the license - contains terms which differ from the Mozilla Public License and - Netscape Public License. (Filling in the name of the Initial - Developer, Original Code or Contributor in the notice described in - Exhibit A shall not of themselves be deemed to be modifications of - this License.) - -7. DISCLAIMER OF WARRANTY. - - COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF - DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. - THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE - IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, - YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE - COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER - OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF - ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - - 8.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to cure - such breach within 30 days of becoming aware of the breach. All - sublicenses to the Covered Code which are properly granted shall - survive any termination of this License. Provisions which, by their - nature, must remain in effect beyond the termination of this License - shall survive. - - 8.2. If You initiate litigation by asserting a patent infringement - claim (excluding declatory judgment actions) against Initial Developer - or a Contributor (the Initial Developer or Contributor against whom - You file such action is referred to as "Participant") alleging that: - - (a) such Participant's Contributor Version directly or indirectly - infringes any patent, then any and all rights granted by such - Participant to You under Sections 2.1 and/or 2.2 of this License - shall, upon 60 days notice from Participant terminate prospectively, - unless if within 60 days after receipt of notice You either: (i) - agree in writing to pay Participant a mutually agreeable reasonable - royalty for Your past and future use of Modifications made by such - Participant, or (ii) withdraw Your litigation claim with respect to - the Contributor Version against such Participant. If within 60 days - of notice, a reasonable royalty and payment arrangement are not - mutually agreed upon in writing by the parties or the litigation claim - is not withdrawn, the rights granted by Participant to You under - Sections 2.1 and/or 2.2 automatically terminate at the expiration of - the 60 day notice period specified above. - - (b) any software, hardware, or device, other than such Participant's - Contributor Version, directly or indirectly infringes any patent, then - any rights granted to You by such Participant under Sections 2.1(b) - and 2.2(b) are revoked effective as of the date You first made, used, - sold, distributed, or had made, Modifications made by that - Participant. - - 8.3. If You assert a patent infringement claim against Participant - alleging that such Participant's Contributor Version directly or - indirectly infringes any patent where such claim is resolved (such as - by license or settlement) prior to the initiation of patent - infringement litigation, then the reasonable value of the licenses - granted by such Participant under Sections 2.1 or 2.2 shall be taken - into account in determining the amount or value of any payment or - license. - - 8.4. In the event of termination under Sections 8.1 or 8.2 above, - all end user license agreements (excluding distributors and resellers) - which have been validly granted by You or any distributor hereunder - prior to termination shall survive termination. - -9. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT - (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL - DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, - OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR - ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY - CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, - WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER - COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN - INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF - LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY - RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW - PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE - EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO - THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - - The Covered Code is a "commercial item," as that term is defined in - 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer - software" and "commercial computer software documentation," as such - terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 - C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), - all U.S. Government End Users acquire Covered Code with only those - rights set forth herein. - -11. MISCELLANEOUS. - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. This License shall be governed by - California law provisions (except to the extent applicable law, if - any, provides otherwise), excluding its conflict-of-law provisions. - With respect to disputes in which at least one party is a citizen of, - or an entity chartered or registered to do business in the United - States of America, any litigation relating to this License shall be - subject to the jurisdiction of the Federal Courts of the Northern - District of California, with venue lying in Santa Clara County, - California, with the losing party responsible for costs, including - without limitation, court costs and reasonable attorneys' fees and - expenses. The application of the United Nations Convention on - Contracts for the International Sale of Goods is expressly excluded. - Any law or regulation which provides that the language of a contract - shall be construed against the drafter shall not apply to this - License. - -12. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or indirectly, - out of its utilization of rights under this License and You agree to - work with Initial Developer and Contributors to distribute such - responsibility on an equitable basis. Nothing herein is intended or - shall be deemed to constitute any admission of liability. - -13. MULTIPLE-LICENSED CODE. - - Initial Developer may designate portions of the Covered Code as - "Multiple-Licensed". "Multiple-Licensed" means that the Initial - Developer permits you to utilize portions of the Covered Code under - Your choice of the NPL or the alternative licenses, if any, specified - by the Initial Developer in the file described in Exhibit A. - -EXHIBIT A - Mozilla Public License. - - ``The contents of this file are subject to the Mozilla Public License - Version 1.1 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - License for the specific language governing rights and limitations - under the License. - - The Original Code is ______________________________________. - - The Initial Developer of the Original Code is ________________________. - Portions created by ______________________ are Copyright (C) ______ - _______________________. All Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the terms - of the _____ license (the "[___] License"), in which case the - provisions of [______] License are applicable instead of those - above. If you wish to allow use of your version of this file only - under the terms of the [____] License and not to allow others to use - your version of this file under the MPL, indicate your decision by - deleting the provisions above and replace them with the notice and - other provisions required by the [___] License. If you do not delete - the provisions above, a recipient may use your version of this file - under either the MPL or the [___] License." - - [NOTE: The text of this Exhibit A may differ slightly from the text of - the notices in the Source Code files of the Original Code. You should - use the text of this Exhibit A rather than the text found in the - Original Code Source Code for Your Modifications.] - ---- end of LICENSE --- - -------------------------------------------------------------------------------- - -%% This notice is provided with respect to SAX 2.0.1, which is included -with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to SAX 2.0.1, which may be included +with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1876,8 +2065,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to SoftFloat version 2b, which is -included with JRE 7, JDK 7, and OpenJDK 7 on Linux/ARM. +%% This notice is provided with respect to SoftFloat version 2b, which may be +included with JRE 8, JDK 8, and OpenJDK 8 on Linux/ARM. --- begin of LICENSE --- @@ -1909,12 +2098,41 @@ ------------------------------------------------------------------------------- +%% This notice is provided with respect to Sparkle 1.5, +which may be included with JRE 8 on Mac OS X. + +--- begin of LICENSE --- + +Copyright (c) 2012 Sparkle.org and Andy Matuschak + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- end of LICENSE --- + +------------------------------------------------------------------------------- + %% Portions licensed from Taligent, Inc. ------------------------------------------------------------------------------- -%% This notice is provided with respect to Thai Dictionary, which is -included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to Thai Dictionary, which may be +included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1947,8 +2165,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to Unicode 6.0.0, CLDR v1.4.1, & CLDR -v1.9, which is included with JRE 7, JDK 7, and OpenJDK 7. +%% This notice is provided with respect to Unicode 6.2.0 & CLDR 21.0.1 +which may be included with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- @@ -1959,7 +2177,7 @@ Trademark Usage Policy. A. Unicode Copyright. - 1. Copyright © 1991-2011 Unicode, Inc. All rights reserved. + 1. Copyright © 1991-2013 Unicode, Inc. All rights reserved. 2. Certain documents and files on this website contain a legend indicating that "Modification is permitted." Any person is hereby authorized, @@ -2094,7 +2312,7 @@ COPYRIGHT AND PERMISSION NOTICE -Copyright © 1991-2011 Unicode, Inc. All rights reserved. Distributed under the +Copyright © 1991-2012 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html. Permission is hereby granted, free of charge, to any person obtaining a copy @@ -2134,8 +2352,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to UPX v3.01, which is included -with JRE 7 on Windows. +%% This notice is provided with respect to UPX v3.01, which may be included +with JRE 8 on Windows. --- begin of LICENSE --- @@ -2274,7 +2492,7 @@ ------------------------------------------------------------------------------- %% This notice is provided with respect to Xfree86-VidMode Extension 1.0, -which is included with JRE 7, JDK 7, and OpenJDK 7 on Linux and Solaris. +which may be included with JRE 8, JDK 8, and OpenJDK 8 on Linux and Solaris. --- begin of LICENSE --- @@ -2326,8 +2544,8 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to X Window System 6.8.2, which is -included with JRE 7, JDK 7, and OpenJDK 7 on Linux and Solaris. +%% This notice is provided with respect to X Window System 6.8.2, which may be +included with JRE 8, JDK 8, and OpenJDK 8 on Linux and Solaris. --- begin of LICENSE --- @@ -3131,12 +3349,12 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to zlib v1.2.3, which is included -with JRE 7, JDK 7, and OpenJDK 7 +%% This notice is provided with respect to zlib v1.2.5, which may be included +with JRE 8, JDK 8, and OpenJDK 8. --- begin of LICENSE --- - version 1.2.3, July 18th, 2005 + version 1.2.5, July 18th, 2005 Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler @@ -3163,16 +3381,18 @@ ------------------------------------------------------------------------------- -%% This notice is provided with respect to the following which is -included with JRE 7, JDK 7, and OpenJDK 7, except where noted: - - Apache Derby 10.8.1.2 [included with JDK 7 only] +%% This notice is provided with respect to the following which may be +included with JRE 8, JDK 8, and OpenJDK 8, except where noted: + + Apache Commons Math 2.2 + Apache Derby 10.10.1.2 [included with JDK 8] Apache Jakarta BCEL 5.2 Apache Jakarta Regexp 1.4 - Apache Santuario XMLSec-Java 1.4.2 + Apache Santuario XML Security for Java 1.5.4 Apache Xalan-Java 2.7.1 - Apache Xerces2 Java 2.10.0 + Apache Xerces Java 2.10.0 Apache XML Resolver 1.1 + Dynalink 0.5 --- begin of LICENSE --- diff -r 6681b9eb3f4c -r b1dded9c748a agent/make/Makefile --- a/agent/make/Makefile Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/make/Makefile Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/make/mkinstall --- a/agent/make/mkinstall Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/make/mkinstall Mon Mar 17 14:30:59 2014 +0100 @@ -27,7 +27,9 @@ cp ../src/os/solaris/proc/amd64/libsaproc.so $SA_NAME/solaris/amd64 cp ../src/os/solaris/proc/sparc/libsaproc.so $SA_NAME/solaris/sparc +cp ../src/os/solaris/proc/sparc/libsaproc_audit.so $SA_NAME/solaris/sparc cp ../src/os/solaris/proc/sparcv9/libsaproc.so $SA_NAME/solaris/sparcv9 +cp ../src/os/solaris/proc/sparcv9/libsaproc_audit.so $SA_NAME/solaris/sparcv9 cp ../src/os/solaris/proc/i386/libsaproc.so $SA_NAME/solaris/i386 cp ../src/os/linux/i386/libsaproc.so $SA_NAME/linux/i386 cp ../src/os/linux/ia64/libsaproc.so $SA_NAME/linux/ia64 diff -r 6681b9eb3f4c -r b1dded9c748a agent/make/saenv.sh --- a/agent/make/saenv.sh Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/make/saenv.sh Mon Mar 17 14:30:59 2014 +0100 @@ -48,16 +48,17 @@ CPU=i386 fi else - # configure audit helper library if SA_ALTROOT is set - if [ -n "$SA_ALTROOT" ]; then - LD_AUDIT_32=$STARTDIR/../src/os/solaris/proc/`uname -p`/libsaproc_audit.so - export LD_AUDIT_32 - if [ ! -f $LD_AUDIT_32 ]; then - echo "SA_ALTROOT is set and can't find libsaproc_audit.so." - echo "Make sure to build it with 'make natives'." - exit 1 - fi + # configure audit helper library for solaris + LD_AUDIT_32=$STARTDIR/../src/os/solaris/proc/`uname -p`/libsaproc_audit.so + if [ ! -f $LD_AUDIT_32 ]; then + LD_AUDIT_32=$STARTDIR/solaris/`uname -p`/libsaproc_audit.so + fi + if [ ! -f $LD_AUDIT_32 ]; then + echo "Can't find libsaproc_audit.so." + echo "Make sure to build it with 'make natives'." + exit 1 fi + export LD_AUDIT_32 SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/`uname -p`:$STARTDIR/solaris/`uname -p` OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger" CPU=sparc diff -r 6681b9eb3f4c -r b1dded9c748a agent/make/saenv64.sh --- a/agent/make/saenv64.sh Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/make/saenv64.sh Mon Mar 17 14:30:59 2014 +0100 @@ -43,16 +43,19 @@ fi fi -# configure audit helper library if SA_ALTROOT is set -if [ -n "$SA_ALTROOT" ]; then - LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so - export LD_AUDIT_64 - if [ ! -f $LD_AUDIT_64 ]; then - echo "SA_ALTROOT is set and can't find libsaproc_audit.so." - echo "Make sure to build it with 'make natives'." - exit 1 - fi +# configure audit helper library +LD_AUDIT_64=$STARTDIR/../src/os/solaris/proc/$CPU/libsaproc_audit.so +if [ ! -f $LD_AUDIT_64 ]; then + LD_AUDIT_64=$STARTDIR/solaris/$CPU/libsaproc_audit.so fi + +if [ ! -f $LD_AUDIT_64 ]; then + echo "Can't find libsaproc_audit.so." + echo "Make sure to build it with 'make natives'." + exit 1 +fi + +export LD_AUDIT_64 SA_LIBPATH=$STARTDIR/../src/os/solaris/proc/$CPU:$STARTDIR/solaris/$CPU OPTIONS="-Dsa.library.path=$SA_LIBPATH -Dsun.jvm.hotspot.debugger.useProcDebugger" diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/linux/libproc.h --- a/agent/src/os/linux/libproc.h Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/linux/libproc.h Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,7 +80,7 @@ *************************************************************************************/ -#if defined(sparc) || defined(sparcv9) +#if defined(sparc) || defined(sparcv9) || defined(ppc64) #define user_regs_struct pt_regs #endif diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/linux/libproc_impl.c --- a/agent/src/os/linux/libproc_impl.c Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/linux/libproc_impl.c Mon Mar 17 14:30:59 2014 +0100 @@ -29,54 +29,51 @@ #include #include "libproc_impl.h" -static const char* alt_root = NULL; -static int alt_root_len = -1; - #define SA_ALTROOT "SA_ALTROOT" -static void init_alt_root() { - if (alt_root_len == -1) { - alt_root = getenv(SA_ALTROOT); - if (alt_root) { - alt_root_len = strlen(alt_root); - } else { - alt_root_len = 0; - } - } -} - int pathmap_open(const char* name) { - int fd; - char alt_path[PATH_MAX + 1]; + static const char *alt_root = NULL; + static int alt_root_initialized = 0; - init_alt_root(); + int fd; + char alt_path[PATH_MAX + 1], *alt_path_end; + const char *s; - if (alt_root_len > 0) { - strcpy(alt_path, alt_root); - strcat(alt_path, name); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - print_debug("path %s substituted for %s\n", alt_path, name); - return fd; - } + if (!alt_root_initialized) { + alt_root_initialized = -1; + alt_root = getenv(SA_ALTROOT); + } + + if (alt_root == NULL) { + return open(name, O_RDONLY); + } + + strcpy(alt_path, alt_root); + alt_path_end = alt_path + strlen(alt_path); - if (strrchr(name, '/')) { - strcpy(alt_path, alt_root); - strcat(alt_path, strrchr(name, '/')); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - print_debug("path %s substituted for %s\n", alt_path, name); - return fd; - } - } - } else { - fd = open(name, O_RDONLY); - if (fd >= 0) { - return fd; - } - } + // Strip path items one by one and try to open file with alt_root prepended + s = name; + while (1) { + strcat(alt_path, s); + s += 1; + + fd = open(alt_path, O_RDONLY); + if (fd >= 0) { + print_debug("path %s substituted for %s\n", alt_path, name); + return fd; + } - return -1; + // Linker always put full path to solib to process, so we can rely + // on presence of /. If slash is not present, it means, that SOlib doesn't + // physically exist (e.g. linux-gate.so) and we fail opening it anyway + if ((s = strchr(s, '/')) == NULL) { + break; + } + + *alt_path_end = 0; + } + + return -1; } static bool _libsaproc_debug; diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/linux/salibelf.c --- a/agent/src/os/linux/salibelf.c Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/linux/salibelf.c Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/linux/symtab.c --- a/agent/src/os/linux/symtab.c Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/linux/symtab.c Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,8 +214,10 @@ + 2); strcpy(debug_pathname, name); char *last_slash = strrchr(debug_pathname, '/'); - if (last_slash == NULL) + if (last_slash == NULL) { + free(debug_pathname); return -1; + } /* Look in the same directory as the object. */ strcpy(last_slash+1, debug_filename); diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/solaris/proc/saproc.cpp --- a/agent/src/os/solaris/proc/saproc.cpp Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/solaris/proc/saproc.cpp Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/os/win32/windbg/sawindbg.cpp --- a/agent/src/os/win32/windbg/sawindbg.cpp Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/os/win32/windbg/sawindbg.cpp Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java --- a/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/CLHSDB.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java --- a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/HSDB.java --- a/agent/src/share/classes/sun/jvm/hotspot/HSDB.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/HSDB.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java --- a/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/LinuxVtblAccess.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java --- a/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/asm/Disassembler.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciEnv.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,9 +95,15 @@ int entryBci = task.osrBci(); int compLevel = task.compLevel(); Klass holder = method.getMethodHolder(); - out.println("compile " + holder.getName().asString() + " " + - OopUtilities.escapeString(method.getName().asString()) + " " + - method.getSignature().asString() + " " + - entryBci + " " + compLevel); + out.print("compile " + holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString() + " " + + entryBci + " " + compLevel); + Compile compiler = compilerData(); + if (compiler != null) { + // Dump inlining data. + compiler.dumpInlineData(out); + } + out.println(); } } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java --- a/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/ci/ciMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java --- a/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/code/NMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java --- a/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/compiler/CompileTask.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdAddress.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/bsd/BsdDebugger.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxAddress.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java Mon Mar 17 14:30:59 2014 +0100 @@ -55,31 +55,21 @@ if (pc == null) { return null; } + + /* Typically we have about ten loaded objects here. So no reason to do + sort/binary search here. Linear search gives us acceptable performance.*/ + List objs = getLoadObjectList(); - Object[] arr = objs.toArray(); - // load objects are sorted by base address, do binary search - int mid = -1; - int low = 0; - int high = arr.length - 1; - while (low <= high) { - mid = (low + high) >> 1; - LoadObject midVal = (LoadObject) arr[mid]; - long cmp = pc.minus(midVal.getBase()); - if (cmp < 0) { - high = mid - 1; - } else if (cmp > 0) { - long size = midVal.getSize(); - if (cmp >= size) { - low = mid + 1; - } else { - return (LoadObject) arr[mid]; - } - } else { // match found - return (LoadObject) arr[mid]; - } + for (int i = 0; i < objs.size(); i++) { + LoadObject ob = (LoadObject) objs.get(i); + Address base = ob.getBase(); + long size = ob.getSize(); + if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) { + return ob; + } } - // no match found. + return null; } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxDebuggerLocal.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxOopHandle.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/amd64/LinuxAMD64CFrame.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/x86/LinuxX86CFrame.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugger.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/amd64/WindowsAMD64CFrame.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java --- a/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/debugger/windows/x86/WindowsX86CFrame.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ArrayTypeImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,19 +24,29 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; import sun.jvm.hotspot.oops.ArrayKlass; +import sun.jvm.hotspot.oops.Instance; import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ObjArrayKlass; -import sun.jvm.hotspot.oops.TypeArrayKlass; import sun.jvm.hotspot.oops.Klass; -import sun.jvm.hotspot.oops.Instance; +import sun.jvm.hotspot.oops.ObjArrayKlass; import sun.jvm.hotspot.oops.Symbol; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; +import sun.jvm.hotspot.oops.TypeArrayKlass; + +import com.sun.jdi.ArrayReference; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.VirtualMachine; public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType { protected ArrayTypeImpl(VirtualMachine aVm, ArrayKlass aRef) { @@ -75,7 +85,8 @@ } } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set handledInterfaces) { // arrays don't have methods } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ClassTypeImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,12 +24,30 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; -import sun.jvm.hotspot.oops.Klass; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.Field; +import com.sun.jdi.IncompatibleThreadStateException; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.InvalidTypeException; +import com.sun.jdi.InvocationException; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public class ClassTypeImpl extends ReferenceTypeImpl implements ClassType @@ -195,22 +213,26 @@ return null; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = interfaces().iterator(); + Iterator iter = interfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } ClassTypeImpl clazz = (ClassTypeImpl)superclass(); if (clazz != null) { - clazz.addVisibleMethods(methodMap); + clazz.addVisibleMethods(methodMap, seenInterfaces); } addToMethodMap(methodMap, methods()); diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/InterfaceTypeImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,15 +24,22 @@ package sun.jvm.hotspot.jdi; -import com.sun.jdi.*; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + import sun.jvm.hotspot.oops.InstanceKlass; -import java.util.List; -import java.util.ArrayList; -import java.util.Map; -import java.util.Iterator; -import java.util.Collections; -import java.lang.ref.SoftReference; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassType; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.VirtualMachine; public class InterfaceTypeImpl extends ReferenceTypeImpl implements InterfaceType { @@ -96,16 +103,20 @@ return implementors; } - void addVisibleMethods(Map methodMap) { + @Override + void addVisibleMethods(Map methodMap, Set seenInterfaces) { /* * Add methods from * parent types first, so that the methods in this class will * overwrite them in the hash table */ - Iterator iter = superinterfaces().iterator(); + Iterator iter = superinterfaces().iterator(); while (iter.hasNext()) { InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next(); - interfaze.addVisibleMethods(methodMap); + if (!seenInterfaces.contains(interfaze)) { + interfaze.addVisibleMethods(methodMap, seenInterfaces); + seenInterfaces.add(interfaze); + } } addToMethodMap(methodMap, methods()); diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/JVMTIThreadState.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java --- a/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/jdi/ReferenceTypeImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,24 +24,45 @@ package sun.jvm.hotspot.jdi; -import java.io.*; - -import com.sun.jdi.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import sun.jvm.hotspot.memory.SystemDictionary; +import sun.jvm.hotspot.oops.ArrayKlass; +import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.oops.Instance; import sun.jvm.hotspot.oops.InstanceKlass; -import sun.jvm.hotspot.oops.ArrayKlass; import sun.jvm.hotspot.oops.JVMDIClassStatus; import sun.jvm.hotspot.oops.Klass; -import sun.jvm.hotspot.oops.ObjArray; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.oops.Symbol; -import sun.jvm.hotspot.oops.DefaultHeapVisitor; import sun.jvm.hotspot.utilities.Assert; -import java.util.*; -import java.lang.ref.SoftReference; +import com.sun.jdi.AbsentInformationException; +import com.sun.jdi.ArrayType; +import com.sun.jdi.ClassLoaderReference; +import com.sun.jdi.ClassNotLoadedException; +import com.sun.jdi.ClassNotPreparedException; +import com.sun.jdi.ClassObjectReference; +import com.sun.jdi.Field; +import com.sun.jdi.InterfaceType; +import com.sun.jdi.Method; +import com.sun.jdi.ObjectReference; +import com.sun.jdi.PrimitiveType; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.Type; +import com.sun.jdi.Value; +import com.sun.jdi.VirtualMachine; public abstract class ReferenceTypeImpl extends TypeImpl implements ReferenceType { @@ -421,7 +442,8 @@ } } - abstract void addVisibleMethods(Map methodMap); + abstract void addVisibleMethods(Map methodMap, Set seenInterfaces); + public final List visibleMethods() throws ClassNotPreparedException { checkPrepared(); /* @@ -430,8 +452,8 @@ * concatenation of name and signature. */ //System.out.println("jj: RTI: Calling addVisibleMethods for:" + this); - Map map = new HashMap(); - addVisibleMethods(map); + Map map = new HashMap(); + addVisibleMethods(map, new HashSet()); /* * ... but the hash map destroys order. Methods should be @@ -441,7 +463,7 @@ */ //System.out.println("jj: RTI: Calling allMethods for:" + this); - List list = new ArrayList(allMethods()); + List list = new ArrayList(allMethods()); //System.out.println("jj: allMethods = " + jjstr(list)); //System.out.println("jj: map = " + map.toString()); //System.out.println("jj: map = " + jjstr(map.values())); diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,77 @@ +/* + * @(#)AdaptiveFreeList.java + * + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.memory; + +import java.util.Observable; +import java.util.Observer; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObject; +import sun.jvm.hotspot.types.CIntegerField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; + +public class AdaptiveFreeList extends VMObject { + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static synchronized void initialize(TypeDataBase db) { + Type type = db.lookupType("AdaptiveFreeList"); + sizeField = type.getCIntegerField("_size"); + countField = type.getCIntegerField("_count"); + headerSize = type.getSize(); + } + + // Fields + private static CIntegerField sizeField; + private static CIntegerField countField; + private static long headerSize; + + //Constructor + public AdaptiveFreeList(Address address) { + super(address); + } + + // Accessors + public long size() { + return sizeField.getValue(addr); + } + + public long count() { + return countField.getValue(addr); + } + + public static long sizeOf() { + return headerSize; + } +} diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java --- a/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CMSCollector.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java --- a/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * 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,25 +24,29 @@ package sun.jvm.hotspot.memory; -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.oops.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Observable; +import java.util.Observer; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.debugger.Debugger; +import sun.jvm.hotspot.oops.ObjectHeap; +import sun.jvm.hotspot.oops.Oop; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObjectFactory; +import sun.jvm.hotspot.types.AddressField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.utilities.Assert; public class CompactibleFreeListSpace extends CompactibleSpace { private static AddressField collectorField; - - // for free size, three fields - // FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks - // FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks - // LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB private static AddressField indexedFreeListField; private static AddressField dictionaryField; private static long smallLinearAllocBlockFieldOffset; - private static long indexedFreeListSizeOf; private int heapWordSize; // 4 for 32bit, 8 for 64 bits private int IndexSetStart; // for small indexed list @@ -109,11 +113,11 @@ // small chunks long size = 0; Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() ); - cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf()); + cur = cur.addOffsetTo(IndexSetStart*AdaptiveFreeList.sizeOf()); for (int i=IndexSetStart; i"); - sizeField = type.getCIntegerField("_size"); - countField = type.getCIntegerField("_count"); - headerSize = type.getSize(); - } - - // Fields - private static CIntegerField sizeField; - private static CIntegerField countField; - private static long headerSize; - - //Constructor - public FreeList(Address address) { - super(address); - } - - // Accessors - public long size() { - return sizeField.getValue(addr); - } - - public long count() { - return countField.getValue(addr); - } - - public static long sizeOf() { - return headerSize; - } -} diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java --- a/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ArrayKlass.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,7 +152,7 @@ private long indexOffset(long index) { if (Assert.ASSERTS_ENABLED) { - Assert.that(index > 0 && index < getLength(), "invalid cp index " + index + " " + getLength()); + Assert.that(index >= 0 && index < getLength(), "invalid cp index " + index + " " + getLength()); } return (index * getElementSize()) + headerSize; } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodCounters.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java --- a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/opto/Block.java --- a/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java Mon Mar 17 14:30:59 2014 +0100 @@ -48,7 +48,7 @@ preOrderField = new CIntField(type.getCIntegerField("_pre_order"), 0); domDepthField = new CIntField(type.getCIntegerField("_dom_depth"), 0); idomField = type.getAddressField("_idom"); - freqField = type.getJFloatField("_freq"); + freqField = type.getJDoubleField("_freq"); } private static AddressField nodesField; @@ -57,7 +57,7 @@ private static CIntField preOrderField; private static CIntField domDepthField; private static AddressField idomField; - private static JFloatField freqField; + private static JDoubleField freqField; public Block(Address addr) { super(addr); @@ -67,8 +67,8 @@ return (int)preOrderField.getValue(getAddress()); } - public float freq() { - return (float)freqField.getValue(getAddress()); + public double freq() { + return (double)freqField.getValue(getAddress()); } public Node_List nodes() { diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java --- a/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/opto/Compile.java Mon Mar 17 14:30:59 2014 +0100 @@ -25,6 +25,7 @@ package sun.jvm.hotspot.opto; import java.util.*; +import java.io.PrintStream; import sun.jvm.hotspot.ci.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; @@ -92,4 +93,13 @@ } return null; } + + public void dumpInlineData(PrintStream out) { + InlineTree inlTree = ilt(); + if (inlTree != null) { + out.print(" inline " + inlTree.count()); + inlTree.dumpReplayData(out); + } + } + } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java --- a/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/opto/InlineTree.java Mon Mar 17 14:30:59 2014 +0100 @@ -87,6 +87,11 @@ return GrowableArray.create(addr, inlineTreeConstructor); } + public int inlineLevel() { + JVMState jvms = callerJvms(); + return (jvms != null) ? jvms.depth() : 0; + } + public void printImpl(PrintStream st, int indent) { for (int i = 0; i < indent; i++) st.print(" "); st.printf(" @ %d ", callerBci()); @@ -101,4 +106,28 @@ public void print(PrintStream st) { printImpl(st, 2); } + + // Count number of nodes in this subtree + public int count() { + int result = 1; + GrowableArray subt = subtrees(); + for (int i = 0 ; i < subt.length(); i++) { + result += subt.at(i).count(); + } + return result; + } + + public void dumpReplayData(PrintStream out) { + out.printf(" %d %d ", inlineLevel(), callerBci()); + Method method = (Method)method().getMetadata(); + Klass holder = method.getMethodHolder(); + out.print(holder.getName().asString() + " " + + OopUtilities.escapeString(method.getName().asString()) + " " + + method.getSignature().asString()); + + GrowableArray subt = subtrees(); + for (int i = 0 ; i < subt.length(); i++) { + subt.at(i).dumpReplayData(out); + } + } } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java --- a/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/opto/JVMState.java Mon Mar 17 14:30:59 2014 +0100 @@ -88,6 +88,10 @@ return (int)bciField.getValue(getAddress()); } + public int depth() { + return (int)depthField.getValue(getAddress()); + } + public JVMState caller() { return create(callerField.getValue(getAddress())); } diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java --- a/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/opto/PhaseCFG.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java --- a/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java Mon Mar 17 14:30:59 2014 +0100 @@ -103,11 +103,12 @@ } SystemDictionary dict = VM.getVM().getSystemDictionary(); - dict.classesDo(new SystemDictionary.ClassAndLoaderVisitor() { - public void visit(Klass k, Oop loader) { + dict.classesDo(new SystemDictionary.ClassVisitor() { + public void visit(Klass k) { if (! (k instanceof InstanceKlass)) { return; } + Oop loader = ((InstanceKlass) k).getClassLoader(); LoaderData ld = (loader != null) ? (LoaderData)loaderMap.get(loader) : bootstrapLoaderData; if (ld != null) { diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ByteCodeRewriter.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,11 +98,14 @@ break; default: throw new IllegalArgumentException(); } + if (cpCache == null) { return (short) cpCacheIndex; } else if (fmt.indexOf("JJJJ") >= 0) { - // change byte-ordering and go via secondary cache entry - throw new InternalError("unimplemented"); + // Invokedynamic require special handling + cpCacheIndex = ~cpCacheIndex; + cpCacheIndex = bytes.swapInt(cpCacheIndex); + return (short) cpCache.getEntryAt(cpCacheIndex).getConstantPoolIndex(); } else if (fmt.indexOf("JJ") >= 0) { // change byte-ordering and go via cache return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex(); diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java --- a/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java --- a/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicTypeDataBase.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java --- a/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/ui/SAPanel.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,8 +61,9 @@ long h = 0; int s = 0; int len = buf.length; + // Emulate the unsigned int in java_lang_String::hash_code while (len-- > 0) { - h = 31*h + (0xFFL & buf[s]); + h = 31*h + (0xFFFFFFFFL & buf[s]); s++; } return h & 0xFFFFFFFFL; diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapGXLWriter.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaInstanceKlass.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff -r 6681b9eb3f4c -r b1dded9c748a agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js --- a/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Mon Mar 17 14:29:45 2014 +0100 +++ b/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -371,19 +371,23 @@ return sa.dbg.lookup(dso, sym); } -// returns the ClosestSymbol or null -function closestSymbolFor(addr) { - if (sa.cdbg == null) { +function loadObjectContainingPC(addr) { + if (sa.cdbg == null) { // no CDebugger support, return null return null; - } else { - var dso = sa.cdbg.loadObjectContainingPC(addr); - if (dso != null) { - return dso.closestSymbolToPC(addr); - } else { - return null; - } - } + } + + return sa.cdbg.loadObjectContainingPC(addr); +} + +// returns the ClosestSymbol or null +function closestSymbolFor(addr) { + var dso = loadObjectContainingPC(addr); + if (dso != null) { + return dso.closestSymbolToPC(addr); + } + + return null; } // Address-to-symbol @@ -804,6 +808,16 @@ // VM type to SA class map var vmType2Class = new Object(); +// C2 only classes +try{ + vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob; + vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob; +} catch(e) { + // Ignore exception. C2 specific objects might be not + // available in client VM +} + + // This is *not* exhaustive. Add more if needed. // code blobs vmType2Class["BufferBlob"] = sapkg.code.BufferBlob; @@ -812,10 +826,8 @@ vmType2Class["SafepointBlob"] = sapkg.code.SafepointBlob; vmType2Class["C2IAdapter"] = sapkg.code.C2IAdapter; vmType2Class["DeoptimizationBlob"] = sapkg.code.DeoptimizationBlob; -vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob; vmType2Class["I2CAdapter"] = sapkg.code.I2CAdapter; vmType2Class["OSRAdapter"] = sapkg.code.OSRAdapter; -vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob; vmType2Class["PCDesc"] = sapkg.code.PCDesc; // interpreter @@ -876,21 +888,29 @@ // returns description of given pointer as a String function whatis(addr) { - addr = any2addr(addr); - var ptrLoc = findPtr(addr); - if (ptrLoc.isUnknown()) { - var vmType = vmTypeof(addr); - if (vmType != null) { - return "pointer to " + vmType.name; - } else { - var sym = closestSymbolFor(addr); - if (sym != null) { - return sym.name + '+' + sym.offset; - } else { - return ptrLoc.toString(); - } - } - } else { - return ptrLoc.toString(); - } + addr = any2addr(addr); + var ptrLoc = findPtr(addr); + if (!ptrLoc.isUnknown()) { + return ptrLoc.toString(); + } + + var vmType = vmTypeof(addr); + if (vmType != null) { + return "pointer to " + vmType.name; + } + + var dso = loadObjectContainingPC(addr); + if (dso == null) { + return ptrLoc.toString(); + } + + var sym = dso.closestSymbolToPC(addr); + if (sym != null) { + return sym.name + '+' + sym.offset; + } + + var s = dso.getName(); + var p = s.lastIndexOf("/"); + var base = dso.getBase(); + return s.substring(p+1, s.length) + '+' + addr.minus(base); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java --- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java Mon Mar 17 14:30:59 2014 +0100 @@ -67,10 +67,10 @@ * * @return sorted list of blocks */ - public static List computeLinearScanOrder(int blockCount, Block startBlock, NodesToDoubles nodeProbabilities) { - List order = new ArrayList<>(); + public static > List computeLinearScanOrder(int blockCount, T startBlock, NodesToDoubles nodeProbabilities) { + List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); - PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); + PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); computeLinearScanOrder(order, worklist, visitedBlocks, nodeProbabilities); assert checkOrder(order, blockCount); return order; @@ -81,10 +81,10 @@ * * @return sorted list of blocks */ - public static List computeCodeEmittingOrder(int blockCount, Block startBlock, NodesToDoubles nodeProbabilities) { - List order = new ArrayList<>(); + public static > List computeCodeEmittingOrder(int blockCount, T startBlock, NodesToDoubles nodeProbabilities) { + List order = new ArrayList<>(); BitSet visitedBlocks = new BitSet(blockCount); - PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); + PriorityQueue worklist = initializeWorklist(startBlock, visitedBlocks, nodeProbabilities); computeCodeEmittingOrder(order, worklist, visitedBlocks, nodeProbabilities); assert checkOrder(order, blockCount); return order; @@ -93,9 +93,9 @@ /** * Iteratively adds paths to the code emission block order. */ - private static void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void computeCodeEmittingOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { while (!worklist.isEmpty()) { - Block nextImportantPath = worklist.poll(); + T nextImportantPath = worklist.poll(); addPathToCodeEmittingOrder(nextImportantPath, order, worklist, visitedBlocks, nodeProbabilities); } } @@ -103,9 +103,9 @@ /** * Iteratively adds paths to the linear scan block order. */ - private static void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void computeLinearScanOrder(List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { while (!worklist.isEmpty()) { - Block nextImportantPath = worklist.poll(); + T nextImportantPath = worklist.poll(); addPathToLinearScanOrder(nextImportantPath, order, worklist, visitedBlocks, nodeProbabilities); } } @@ -113,8 +113,8 @@ /** * Initializes the priority queue used for the work list of blocks and adds the start block. */ - private static PriorityQueue initializeWorklist(Block startBlock, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - PriorityQueue result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator(nodeProbabilities)); + private static > PriorityQueue initializeWorklist(T startBlock, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + PriorityQueue result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator(nodeProbabilities)); result.add(startBlock); visitedBlocks.set(startBlock.getId()); return result; @@ -123,17 +123,17 @@ /** * Add a linear path to the linear scan order greedily following the most likely successor. */ - private static void addPathToLinearScanOrder(Block block, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + private static > void addPathToLinearScanOrder(T block, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { block.setLinearScanNumber(order.size()); order.add(block); - Block mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); + T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); enqueueSuccessors(block, worklist, visitedBlocks); if (mostLikelySuccessor != null) { if (!mostLikelySuccessor.isLoopHeader() && mostLikelySuccessor.getPredecessorCount() > 1) { // We are at a merge. Check probabilities of predecessors that are not yet // scheduled. double unscheduledSum = 0.0; - for (Block pred : mostLikelySuccessor.getPredecessors()) { + for (T pred : mostLikelySuccessor.getPredecessors()) { if (pred.getLinearScanNumber() == -1) { unscheduledSum += nodeProbabilities.get(pred.getBeginNode()); } @@ -152,8 +152,9 @@ /** * Add a linear path to the code emission order greedily following the most likely successor. */ - private static void addPathToCodeEmittingOrder(Block initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - Block block = initialBlock; + @SuppressWarnings("unchecked") + private static > void addPathToCodeEmittingOrder(T initialBlock, List order, PriorityQueue worklist, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + T block = initialBlock; while (block != null) { // Skip loop headers if there is only a single loop end block to // make the backward jump be a conditional jump. @@ -171,7 +172,7 @@ // This is the only loop end of a skipped loop header. // Add the header immediately afterwards. - addBlock(loop.header, order); + addBlock((T) loop.header, order); // Make sure the loop successors of the loop header are aligned // as they are the target @@ -183,7 +184,7 @@ } } - Block mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); + T mostLikelySuccessor = findAndMarkMostLikelySuccessor(block, visitedBlocks, nodeProbabilities); enqueueSuccessors(block, worklist, visitedBlocks); block = mostLikelySuccessor; } @@ -192,7 +193,7 @@ /** * Adds a block to the ordering. */ - private static void addBlock(Block header, List order) { + private static > void addBlock(T header, List order) { assert !order.contains(header) : "Cannot insert block twice"; order.add(header); } @@ -200,9 +201,9 @@ /** * Find the highest likely unvisited successor block of a given block. */ - private static Block findAndMarkMostLikelySuccessor(Block block, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { - Block result = null; - for (Block successor : block.getSuccessors()) { + private static > T findAndMarkMostLikelySuccessor(T block, BitSet visitedBlocks, NodesToDoubles nodeProbabilities) { + T result = null; + for (T successor : block.getSuccessors()) { assert nodeProbabilities.get(successor.getBeginNode()) >= 0.0 : "Probabilities must be positive"; if (!visitedBlocks.get(successor.getId()) && successor.getLoopDepth() >= block.getLoopDepth() && (result == null || nodeProbabilities.get(successor.getBeginNode()) >= nodeProbabilities.get(result.getBeginNode()))) { @@ -218,8 +219,8 @@ /** * Add successor blocks into the given work list if they are not already marked as visited. */ - private static void enqueueSuccessors(Block block, PriorityQueue worklist, BitSet visitedBlocks) { - for (Block successor : block.getSuccessors()) { + private static > void enqueueSuccessors(T block, PriorityQueue worklist, BitSet visitedBlocks) { + for (T successor : block.getSuccessors()) { if (!visitedBlocks.get(successor.getId())) { visitedBlocks.set(successor.getId()); worklist.add(successor); @@ -231,14 +232,14 @@ * Skip the loop header block if the loop consists of more than one block and it has only a * single loop end block. */ - private static boolean skipLoopHeader(Block block) { + private static boolean skipLoopHeader(AbstractBlock block) { return (block.isLoopHeader() && !block.isLoopEnd() && block.getLoop().loopBegin().loopEnds().count() == 1); } /** * Checks that the ordering contains the expected number of blocks. */ - private static boolean checkOrder(List order, int expectedBlockCount) { + private static boolean checkOrder(List> order, int expectedBlockCount) { assert order.size() == expectedBlockCount : String.format("Number of blocks in ordering (%d) does not match expected block count (%d)", order.size(), expectedBlockCount); return true; } @@ -246,7 +247,7 @@ /** * Comparator for sorting blocks based on loop depth and probability. */ - private static class BlockOrderComparator implements Comparator { + private static class BlockOrderComparator> implements Comparator { private final NodesToDoubles probabilities; @@ -255,7 +256,7 @@ } @Override - public int compare(Block a, Block b) { + public int compare(T a, T b) { // Loop blocks before any loop exit block. int diff = b.getLoopDepth() - a.getLoopDepth(); if (diff != 0) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java --- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java Mon Mar 17 14:30:59 2014 +0100 @@ -146,7 +146,6 @@ case Short: case Int: case Long: - case NarrowOop: case Object: return true; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Architecture.java Mon Mar 17 14:30:59 2014 +0100 @@ -198,8 +198,6 @@ return 8; case Object: return wordSize; - case NarrowOop: - return wordSize / 2; default: return 0; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Assumptions.java Mon Mar 17 14:30:59 2014 +0100 @@ -64,7 +64,7 @@ public boolean equals(Object obj) { if (obj instanceof NoFinalizableSubclass) { NoFinalizableSubclass other = (NoFinalizableSubclass) obj; - return other.receiverType == receiverType; + return other.receiverType.equals(receiverType); } return false; } @@ -112,7 +112,7 @@ public boolean equals(Object obj) { if (obj instanceof ConcreteSubtype) { ConcreteSubtype other = (ConcreteSubtype) obj; - return other.context == context && other.subtype == subtype; + return other.context.equals(context) && other.subtype.equals(subtype); } return false; } @@ -166,7 +166,7 @@ public boolean equals(Object obj) { if (obj instanceof ConcreteMethod) { ConcreteMethod other = (ConcreteMethod) obj; - return other.method == method && other.context == context && other.impl == impl; + return other.method.equals(method) && other.context.equals(context) && other.impl.equals(impl); } return false; } @@ -197,9 +197,9 @@ @Override public boolean equals(Object obj) { - if (obj instanceof ConcreteMethod) { - ConcreteMethod other = (ConcreteMethod) obj; - return other.method == method; + if (obj instanceof MethodContents) { + MethodContents other = (MethodContents) obj; + return other.method.equals(method); } return false; } @@ -387,7 +387,7 @@ } } - out.printf("%d assumptions:\n", nonNullList.size()); + out.printf("%d assumptions:%n", nonNullList.size()); for (Assumption a : nonNullList) { out.println(a.toString()); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java Mon Mar 17 14:30:59 2014 +0100 @@ -71,7 +71,7 @@ * CSA * @param registers the registers that can be saved in the CSA */ - public CalleeSaveLayout(Architecture architecture, int frameOffsetToCSA, int size, int slotSize, Register... registers) { + public CalleeSaveLayout(TargetDescription target, int frameOffsetToCSA, int size, int slotSize, Register... registers) { this.frameOffsetToCSA = frameOffsetToCSA; assert slotSize == 0 || CodeUtil.isPowerOf2(slotSize); this.slotSize = slotSize; @@ -88,8 +88,8 @@ if (offset > maxOffset) { maxOffset = offset; } - PlatformKind kind = architecture.getLargestStorableKind(reg.getRegisterCategory()); - offset += architecture.getSizeInBytes(kind); + PlatformKind kind = target.arch.getLargestStorableKind(reg.getRegisterCategory()); + offset += target.getSizeInBytes(kind); } if (size == -1) { this.size = offset; @@ -106,8 +106,8 @@ int index = offset / slotSize; regNumToIndex[reg.number] = index; indexToReg[index] = reg; - PlatformKind kind = architecture.getLargestStorableKind(reg.getRegisterCategory()); - offset += architecture.getSizeInBytes(kind); + PlatformKind kind = target.arch.getLargestStorableKind(reg.getRegisterCategory()); + offset += target.getSizeInBytes(kind); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeCacheProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,6 +22,7 @@ */ package com.oracle.graal.api.code; +import com.oracle.graal.api.code.CompilationResult.Data; import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.meta.*; @@ -85,6 +86,11 @@ boolean needsDataPatch(Constant constant); /** + * Create a {@link Data} item for a {@link Constant}, that can be used in a {@link DataPatch}. + */ + Data createDataItem(Constant constant, int alignment); + + /** * Gets a description of the target architecture. */ TargetDescription getTarget(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CodeUtil.java Mon Mar 17 14:30:59 2014 +0100 @@ -281,6 +281,17 @@ } } + public static class NumberedRefMapFormatter implements RefMapFormatter { + + public String formatStackSlot(int frameRefMapIndex) { + return "s" + frameRefMapIndex; + } + + public String formatRegister(int regRefMapIndex) { + return "r" + regRefMapIndex; + } + } + /** * Appends a formatted debug info to a {@link StringBuilder}. * @@ -288,7 +299,11 @@ * @param info the debug info to format and append to {@code sb} * @return the value of {@code sb} */ - public static StringBuilder append(StringBuilder sb, DebugInfo info, RefMapFormatter formatter) { + public static StringBuilder append(StringBuilder sb, DebugInfo info, RefMapFormatter formatterArg) { + RefMapFormatter formatter = formatterArg; + if (formatter == null) { + formatter = new NumberedRefMapFormatter(); + } String nl = NEW_LINE; ReferenceMap refMap = info.getReferenceMap(); if (refMap != null && refMap.hasRegisterRefMap()) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Mon Mar 17 14:30:59 2014 +0100 @@ -28,6 +28,7 @@ import java.nio.*; import java.util.*; +import com.oracle.graal.api.code.CodeUtil.*; import com.oracle.graal.api.meta.*; /** @@ -152,66 +153,64 @@ return alignment; } - public abstract int getSize(Architecture arch); + public abstract int getSize(TargetDescription target); - public abstract void emit(Architecture arch, ByteBuffer buffer); + public abstract Kind getKind(); + + public abstract void emit(TargetDescription target, ByteBuffer buffer); } - public static final class ConstantData extends Data { + /** + * Represents a Java primitive value used in a {@link DataPatch}. This implementation uses + * {@link Kind#getByteCount()} bytes to encode each value. + */ + public static final class PrimitiveData extends Data { public final Constant constant; - public ConstantData(Constant constant, int alignment) { + public PrimitiveData(Constant constant, int alignment) { super(alignment); + assert constant.getKind().isPrimitive(); this.constant = constant; } @Override - public int getSize(Architecture arch) { - return arch.getSizeInBytes(constant.getPlatformKind()); + public int getSize(TargetDescription target) { + return constant.getKind().getByteCount(); + } + + @Override + public Kind getKind() { + return constant.getKind(); } @Override - public void emit(Architecture arch, ByteBuffer buffer) { + public void emit(TargetDescription target, ByteBuffer buffer) { switch (constant.getKind()) { case Boolean: - assert getSize(arch) == 1; buffer.put(constant.asBoolean() ? (byte) 1 : (byte) 0); break; case Byte: - assert getSize(arch) == 1; buffer.put((byte) constant.asInt()); break; case Char: - assert getSize(arch) == 2; buffer.putChar((char) constant.asInt()); break; case Short: - assert getSize(arch) == 2; buffer.putShort((short) constant.asInt()); break; case Int: - assert getSize(arch) == 4; buffer.putInt(constant.asInt()); break; case Long: - assert getSize(arch) == 8; buffer.putLong(constant.asLong()); break; case Float: - assert getSize(arch) == 4; buffer.putFloat(constant.asFloat()); break; case Double: - assert getSize(arch) == 8; buffer.putDouble(constant.asDouble()); break; - case Object: - // placeholder for oop value - for (int i = 0; i < getSize(arch); i++) { - buffer.put((byte) 0); - } - break; } } @@ -219,6 +218,24 @@ public String toString() { return constant.toString(); } + + @Override + public int hashCode() { + return constant.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof PrimitiveData) { + PrimitiveData other = (PrimitiveData) obj; + return constant.equals(other.constant); + } else { + return false; + } + } } public static final class RawData extends Data { @@ -231,12 +248,17 @@ } @Override - public int getSize(Architecture arch) { + public int getSize(TargetDescription target) { return data.length; } @Override - public void emit(Architecture arch, ByteBuffer buffer) { + public Kind getKind() { + return Kind.Illegal; + } + + @Override + public void emit(TargetDescription target, ByteBuffer buffer) { buffer.put(data); } @@ -250,6 +272,24 @@ } return ret.toString(); } + + @Override + public int hashCode() { + return Arrays.hashCode(data); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof RawData) { + RawData other = (RawData) obj; + return Arrays.equals(data, other.data); + } else { + return false; + } + } } /** @@ -260,53 +300,18 @@ public static final class DataPatch extends Site { private static final long serialVersionUID = 5771730331604867476L; - public Data externalData; - public Constant inlineData; - - DataPatch(int pcOffset, Data externalData) { - this(pcOffset, externalData, null); - } - - DataPatch(int pcOffset, Constant inlineData) { - this(pcOffset, null, inlineData); - } - - private DataPatch(int pcOffset, Data externalData, Constant inlineData) { - super(pcOffset); - assert (externalData == null) != (inlineData == null) : "data patch can not be both external and inlined"; - this.externalData = externalData; - this.inlineData = inlineData; - } + public Data data; + public boolean inline; - public Constant getConstant() { - if (inlineData != null) { - return inlineData; - } else if (externalData instanceof ConstantData) { - return ((ConstantData) externalData).constant; - } else { - return null; - } - } - - public int getAlignment() { - if (externalData instanceof ConstantData) { - return ((ConstantData) externalData).getAlignment(); - } else { - return 0; - } - } - - public String getDataString() { - if (inlineData != null) { - return inlineData.toString(); - } else { - return externalData.toString(); - } + public DataPatch(int pcOffset, Data data, boolean inline) { + super(pcOffset); + this.data = data; + this.inline = inline; } @Override public String toString() { - return String.format("%d[]", pcOffset, getDataString()); + return String.format("%d[]", pcOffset, inline ? "inline" : "external", data.toString()); } } @@ -464,13 +469,6 @@ private Assumptions assumptions; - /** - * The leafGraphIds will contain the StructuredGraph.graphId()s of the graphs that were - * incorporated into this compilation. These ids are later on used by the runtime system to - * evict graphs from the graph cache when deoptimizations occur. - */ - private long[] leafGraphIds; - public CompilationResult() { this(null); } @@ -515,14 +513,6 @@ return assumptions; } - public void setLeafGraphIds(long[] leafGraphIds) { - this.leafGraphIds = leafGraphIds; - } - - public long[] getLeafGraphIds() { - return leafGraphIds; - } - /** * Sets the frame size in bytes. Does not include the return address pushed onto the stack, if * any. @@ -553,18 +543,18 @@ */ public void recordDataReference(int codePos, Data data) { assert codePos >= 0 && data != null; - dataReferences.add(new DataPatch(codePos, data)); + dataReferences.add(new DataPatch(codePos, data, false)); } /** * Records a reference to an inlined constant in the code section (e.g. to load a constant oop). * * @param codePos the position in the code where the inlined constant occurs - * @param constant the constant that is referenced + * @param data the data that is referenced */ - public void recordInlineData(int codePos, Constant constant) { - assert codePos >= 0 && constant != null; - dataReferences.add(new DataPatch(codePos, constant)); + public void recordInlineData(int codePos, Data data) { + assert codePos >= 0 && data != null; + dataReferences.add(new DataPatch(codePos, data, true)); } /** @@ -706,14 +696,15 @@ if (info != null) { ReferenceMap refMap = info.getReferenceMap(); if (refMap != null) { + RefMapFormatter formatter = new CodeUtil.NumberedRefMapFormatter(); if (refMap.hasFrameRefMap()) { sb.append(" stackMap["); - refMap.appendFrameMap(sb, null); + refMap.appendFrameMap(sb, formatter); sb.append(']'); } if (refMap.hasRegisterRefMap()) { sb.append(" registerMap["); - refMap.appendRegisterMap(sb, null); + refMap.appendRegisterMap(sb, formatter); sb.append(']'); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,8 +22,6 @@ */ package com.oracle.graal.api.code; -import java.io.*; - /** * Represents the debugging information for a particular point of execution. This information * includes: @@ -35,9 +33,7 @@ *
  • a map from the registers (in the caller's frame) to the slots where they are saved in the * current frame
  • */ -public class DebugInfo implements Serializable { - - private static final long serialVersionUID = -6047206624915812516L; +public class DebugInfo { private final BytecodePosition bytecodePosition; private final ReferenceMap referenceMap; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,123 +22,20 @@ */ package com.oracle.graal.api.code; -import java.io.*; -import java.util.*; - import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; - -public class ReferenceMap implements Serializable { - - private static final long serialVersionUID = -1052183095979496819L; - - /** - * Contains 2 bits per register. - *
      - *
    • bit0 = 0: contains no references
    • - *
    • bit0 = 1, bit1 = 0: contains a wide oop
    • - *
    • bit0 = 1, bit1 = 1: contains a narrow oop
    • - *
    - */ - private final BitSet registerRefMap; - - /** - * Contains 3 bits per stack slot. - *
      - *
    • bit0 = 0: contains no references
    • - *
    • bit0 = 1, bit1+2 = 0: contains a wide oop
    • - *
    • bit0 = 1, bit1 = 1: contains a narrow oop in the lower half
    • - *
    • bit0 = 1, bit2 = 1: contains a narrow oop in the upper half
    • - *
    - */ - private final BitSet frameRefMap; +import com.oracle.graal.api.meta.*; - public ReferenceMap(int registerCount, int frameSlotCount) { - if (registerCount > 0) { - this.registerRefMap = new BitSet(registerCount * 2); - } else { - this.registerRefMap = null; - } - this.frameRefMap = new BitSet(frameSlotCount * 3); - } +public interface ReferenceMap { - public void setRegister(int idx, boolean narrow) { - registerRefMap.set(2 * idx); - if (narrow) { - registerRefMap.set(2 * idx + 1); - } - } + void setRegister(int idx, PlatformKind kind); - public void setStackSlot(int idx, boolean narrow1, boolean narrow2) { - frameRefMap.set(3 * idx); - if (narrow1) { - frameRefMap.set(3 * idx + 1); - } - if (narrow2) { - frameRefMap.set(3 * idx + 2); - } - } - - public boolean hasRegisterRefMap() { - return registerRefMap != null && registerRefMap.size() > 0; - } + void setStackSlot(int offset, PlatformKind kind); - public boolean hasFrameRefMap() { - return frameRefMap != null && frameRefMap.size() > 0; - } - - public interface Iterator { - void register(int idx, boolean narrow); - - void stackSlot(int idx, boolean narrow1, boolean narrow2); - } + boolean hasRegisterRefMap(); - public void iterate(Iterator iterator) { - if (hasRegisterRefMap()) { - for (int i = 0; i < registerRefMap.size() / 2; i++) { - if (registerRefMap.get(2 * i)) { - iterator.register(i, registerRefMap.get(2 * i + 1)); - } - } - } - if (hasFrameRefMap()) { - for (int i = 0; i < frameRefMap.size() / 3; i++) { - if (frameRefMap.get(3 * i)) { - iterator.stackSlot(i, frameRefMap.get(3 * i + 1), frameRefMap.get(3 * i + 2)); - } - } - } - } - - private static class NumberedRefMapFormatter implements RefMapFormatter { + boolean hasFrameRefMap(); - public String formatStackSlot(int frameRefMapIndex) { - return "s" + frameRefMapIndex; - } - - public String formatRegister(int regRefMapIndex) { - return "r" + regRefMapIndex; - } - } - - public void appendRegisterMap(StringBuilder sb, RefMapFormatter formatterArg) { - RefMapFormatter formatter = formatterArg; - if (formatter == null) { - formatter = new NumberedRefMapFormatter(); - } + void appendRegisterMap(StringBuilder sb, RefMapFormatter formatterArg); - for (int reg = registerRefMap.nextSetBit(0); reg >= 0; reg = registerRefMap.nextSetBit(reg + 2)) { - sb.append(' ').append(formatter.formatRegister(reg / 2)); - } - } - - public void appendFrameMap(StringBuilder sb, RefMapFormatter formatterArg) { - RefMapFormatter formatter = formatterArg; - if (formatter == null) { - formatter = new NumberedRefMapFormatter(); - } - - for (int slot = frameRefMap.nextSetBit(0); slot >= 0; slot = frameRefMap.nextSetBit(slot + 3)) { - sb.append(' ').append(formatter.formatStackSlot(slot / 3)); - } - } + void appendFrameMap(StringBuilder sb, RefMapFormatter formatterArg); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,16 +22,12 @@ */ package com.oracle.graal.api.code; -import java.io.*; - import com.oracle.graal.api.meta.*; /** * Represents a target machine register. */ -public final class Register implements Comparable, Serializable { - - private static final long serialVersionUID = -7213269157816016300L; +public final class Register implements Comparable { public static final RegisterCategory SPECIAL = new RegisterCategory("SPECIAL"); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java Mon Mar 17 14:30:59 2014 +0100 @@ -28,7 +28,7 @@ * Represents the target machine for a compiler, including the CPU architecture, the size of * pointers and references, alignment of stacks, caches, etc. */ -public class TargetDescription { +public abstract class TargetDescription { public final Architecture arch; @@ -81,4 +81,10 @@ this.implicitNullCheckLimit = implicitNullCheckLimit; this.inlineObjects = inlineObjects; } + + public int getSizeInBytes(PlatformKind kind) { + return arch.getSizeInBytes(kind); + } + + public abstract ReferenceMap createReferenceMap(boolean hasRegisters, int stackSlotCount); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java Mon Mar 17 14:30:59 2014 +0100 @@ -87,7 +87,7 @@ } } else { ResolvedJavaField[] fields = vo.type.getInstanceFields(true); - assert fields.length == vo.values.length : vo.type + ", fields=" + Arrays.toString(fields) + ", values=" + vo.values; + assert fields.length == vo.values.length : vo.type + ", fields=" + Arrays.toString(fields) + ", values=" + Arrays.toString(vo.values); for (int i = 0; i < vo.values.length; i++) { if (i != 0) { buf.append(','); @@ -185,11 +185,11 @@ } if (o instanceof VirtualObject) { VirtualObject l = (VirtualObject) o; - if (l.type != type || l.values.length != values.length) { + if (!l.type.equals(type) || l.values.length != values.length) { return false; } for (int i = 0; i < values.length; i++) { - if (values[i] != l.values[i]) { + if (!Objects.equals(values[i], l.values[i])) { return false; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -77,22 +77,6 @@ } } - /** - * @see ResolvedJavaMethod#getCompiledCodeSize() - */ - @Test - public void getCompiledCodeSizeTest() { - for (Map.Entry e : methods.entrySet()) { - ResolvedJavaMethod m = e.getValue(); - int size = m.getCompiledCodeSize(); - if (isAbstract(m.getModifiers())) { - assertTrue(size == 0); - } else { - assertTrue(size >= 0); - } - } - } - @Test public void getModifiersTest() { for (Map.Entry e : methods.entrySet()) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractJavaProfile.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractJavaProfile.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AbstractJavaProfile.java Mon Mar 17 14:30:59 2014 +0100 @@ -43,7 +43,7 @@ public AbstractJavaProfile(double notRecordedProbability, T[] pitems) { this.pitems = pitems; - assert notRecordedProbability != Double.NaN; + assert !Double.isNaN(notRecordedProbability); this.notRecordedProbability = notRecordedProbability; assert isSorted(); } @@ -124,28 +124,26 @@ } @Override - public boolean equals(Object other) { - if (other == this) { + public boolean equals(Object obj) { + if (obj == this) { return true; } - if (getClass() == other.getClass()) { - AbstractJavaProfile javaTypeProfile = (AbstractJavaProfile) other; - if (javaTypeProfile.notRecordedProbability != notRecordedProbability) { + if (!(obj instanceof AbstractJavaProfile)) { + return false; + } + AbstractJavaProfile that = (AbstractJavaProfile) obj; + if (that.notRecordedProbability != notRecordedProbability) { + return false; + } + if (that.pitems.length != pitems.length) { + return false; + } + for (int i = 0; i < pitems.length; ++i) { + if (!pitems[i].equals(that.pitems[i])) { return false; } - if (javaTypeProfile.pitems.length != pitems.length) { - return false; - } - - for (int i = 0; i < pitems.length; ++i) { - if (!pitems[i].equals(javaTypeProfile.pitems[i])) { - return false; - } - } - - return true; } - return false; + return true; } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java Mon Mar 17 14:30:59 2014 +0100 @@ -159,7 +159,6 @@ case Double: return asDouble(); case Object: - case NarrowOop: return object; case Illegal: return this; @@ -172,7 +171,7 @@ if (!ignoreKind && getKind() != other.getKind()) { return false; } - if (getKind() == Kind.Object || getKind() == Kind.NarrowOop) { + if (getKind() == Kind.Object) { return object == other.object; } return primitive == other.primitive && getPrimitiveAnnotation() == other.getPrimitiveAnnotation(); @@ -235,12 +234,12 @@ /** * Returns the object reference this constant represents. The constant must have kind - * {@link Kind#Object} or {@link Kind#NarrowOop}. + * {@link Kind#Object}. * * @return the constant value */ public Object asObject() { - assert getKind() == Kind.Object || getKind() == Kind.NarrowOop; + assert getKind() == Kind.Object; return object; } @@ -250,7 +249,7 @@ * @return null if this constant is not primitive or has no annotation */ public Object getPrimitiveAnnotation() { - return getKind() == Kind.Object || getKind() == Kind.NarrowOop ? null : object; + return getKind() == Kind.Object ? null : object; } /** @@ -260,7 +259,7 @@ */ @Override public int hashCode() { - if (getKind() == Kind.Object || getKind() == Kind.NarrowOop) { + if (getKind() == Kind.Object) { return System.identityHashCode(object); } return (int) primitive * getKind().ordinal(); @@ -394,16 +393,6 @@ } /** - * Creates a boxed narrow oop constant. - * - * @param o the object value to box - * @return a boxed copy of {@code value} - */ - public static Constant forNarrowOop(Object o) { - return new Constant(Kind.NarrowOop, o, 0L); - } - - /** * Creates an annotated int or long constant. An annotation enables a client to associate some * extra semantic or debugging information with a primitive. An annotated primitive constant is * never {@linkplain #equals(Object) equal} to a non-annotated constant. @@ -463,8 +452,6 @@ return forDouble((Double) value); case Object: return forObject(value); - case NarrowOop: - return forNarrowOop(value); default: throw new RuntimeException("cannot create Constant for boxed " + kind + " value"); } @@ -497,8 +484,6 @@ return LONG_0; case Object: return NULL_OBJECT; - case NarrowOop: - return forNarrowOop(null); default: throw new IllegalArgumentException(kind.toString()); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/DefaultProfilingInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -99,4 +99,12 @@ public void setMature() { // Do nothing } + + public boolean setCompilerIRSize(Class irType, int nodeCount) { + return false; + } + + public int getCompilerIRSize(Class irType) { + return -1; + } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.api.meta; +import java.util.*; + /** * Represents an exception handler within the bytecodes. */ @@ -97,14 +99,14 @@ @Override public boolean equals(Object obj) { + if (!(obj instanceof ExceptionHandler)) { + return false; + } ExceptionHandler that = (ExceptionHandler) obj; if (this.startBCI != that.startBCI || this.endBCI != that.endBCI || this.handlerBCI != that.handlerBCI || this.catchTypeCPI != that.catchTypeCPI) { return false; } - if (this.catchType == null || that.catchType == null) { - return this.catchType == that.catchType; - } - return this.catchType.equals(that.catchType); + return Objects.equals(this.catchType, that.catchType); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java Mon Mar 17 14:30:59 2014 +0100 @@ -57,9 +57,6 @@ /** The Object kind, also used for arrays. */ Object('a', "Object", false, null, null), - /** The narrow oop kind. */ - NarrowOop('n', "NarrowOop", false, null, null), - /** The void float kind. */ Void('v', "void", false, java.lang.Void.TYPE, java.lang.Void.class), @@ -149,10 +146,10 @@ /** * Checks whether this represent an Object of some sort. * - * @return {@code true} if this is {@link #Object} or {@link #NarrowOop}. + * @return {@code true} if this is {@link #Object}. */ public boolean isObject() { - return this == Kind.Object || this == Kind.NarrowOop; + return this == Kind.Object; } /** diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ProfilingInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -114,6 +114,25 @@ int getDeoptimizationCount(DeoptimizationReason reason); /** + * Records the size of the compiler intermediate representation (IR) associated with this + * method. + * + * @param irType the IR type for which the size is being recorded + * @param irSize the IR size to be recorded. The unit depends on the IR. + * @return whether recording this information for {@code irType} is supported + */ + boolean setCompilerIRSize(Class irType, int irSize); + + /** + * Gets the size of the compiler intermediate representation (IR) associated with this method + * last recorded by {@link #setCompilerIRSize(Class, int)}. + * + * @param irType the IR type for which the size is being requested + * @return the requested IR size or -1 if it is unavailable for {@code irType} + */ + int getCompilerIRSize(Class irType); + + /** * Returns true if the profiling information can be assumed as sufficiently accurate. * * @return true if the profiling information was recorded often enough mature enough, false @@ -124,6 +143,5 @@ /** * Force data to be treated as mature if possible. */ - void setMature(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,7 +24,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.*; /** * Represents a resolved Java method. Methods, like fields and types, are resolved through @@ -54,13 +53,6 @@ int getCodeSize(); /** - * Returns the size of the compiled machine code of this method. - * - * @return the size of the compiled machine code in bytes, or 0 if no compiled code exists. - */ - int getCompiledCodeSize(); - - /** * Returns the {@link ResolvedJavaType} object representing the class or interface that declares * this method. */ @@ -144,12 +136,6 @@ void reprofile(); /** - * Returns a map that the compiler can use to store objects that should survive the current - * compilation. - */ - Map getCompilerStorage(); - - /** * Returns the constant pool of this method. */ ConstantPool getConstantPool(); @@ -185,6 +171,9 @@ */ boolean canBeInlined(); + /** + * Returns {@code true} if the inlining of this method should be forced. + */ boolean shouldBeInlined(); /** diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Mon Mar 17 14:30:59 2014 +0100 @@ -87,8 +87,8 @@ @Override public boolean equals(Object obj) { if (obj instanceof Value) { - Value other = (Value) obj; - return kind.equals(other.kind) && platformKind.equals(platformKind); + Value that = (Value) obj; + return kind.equals(that.kind) && platformKind.equals(that.platformKind); } return false; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java --- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,13 +22,27 @@ */ package com.oracle.graal.api.runtime; +import java.lang.reflect.*; + +import sun.reflect.*; + public class Graal { private static GraalRuntime runtime; private static native GraalRuntime initializeRuntime(); + public static final java.security.Permission ACCESS_PERMISSION = new ReflectPermission("allowGraalAccess"); + + @CallerSensitive public static GraalRuntime getRuntime() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + Class cc = Reflection.getCallerClass(); + if (cc.getClassLoader() != null) { + sm.checkPermission(ACCESS_PERMISSION); + } + } return runtime; } @@ -38,9 +52,19 @@ } catch (UnsatisfiedLinkError e) { runtime = new InvalidGraalRuntime(); } + + Reflection.registerFieldsToFilter(Graal.class, "runtime"); } + @CallerSensitive public static T getRequiredCapability(Class clazz) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + Class cc = Reflection.getCallerClass(); + if (cc.getClassLoader() != null) { + sm.checkPermission(ACCESS_PERMISSION); + } + } T t = getRuntime().getCapability(clazz); if (t == null) { String javaHome = System.getProperty("java.home"); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java --- a/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.asm.amd64.test/src/com/oracle/graal/asm/amd64/test/SimpleAssemblerTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,7 +27,7 @@ import org.junit.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.ConstantData; +import com.oracle.graal.api.code.CompilationResult.PrimitiveData; import com.oracle.graal.api.code.CompilationResult.RawData; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; @@ -59,7 +59,7 @@ public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) { AMD64MacroAssembler asm = new AMD64MacroAssembler(target, registerConfig); Register ret = registerConfig.getReturnRegister(Kind.Double); - compResult.recordDataReference(asm.position(), new ConstantData(Constant.forDouble(84.72), 8)); + compResult.recordDataReference(asm.position(), new PrimitiveData(Constant.forDouble(84.72), 8)); asm.movdbl(ret, asm.getPlaceholder()); asm.ret(0); return asm.close(true); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java --- a/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.asm.amd64/src/com/oracle/graal/asm/amd64/AMD64MacroAssembler.java Mon Mar 17 14:30:59 2014 +0100 @@ -261,7 +261,7 @@ private AMD64Address trigPrologue(Register value) { assert value.getRegisterCategory() == AMD64.XMM; AMD64Address tmp = new AMD64Address(AMD64.rsp); - subq(AMD64.rsp, target.arch.getSizeInBytes(Kind.Double)); + subq(AMD64.rsp, target.getSizeInBytes(Kind.Double)); movdbl(tmp, value); fldd(tmp); return tmp; @@ -271,7 +271,7 @@ assert dest.getRegisterCategory() == AMD64.XMM; fstpd(tmp); movdbl(dest, tmp); - addq(AMD64.rsp, target.arch.getSizeInBytes(Kind.Double)); + addq(AMD64.rsp, target.getSizeInBytes(Kind.Double)); } /** diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java --- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Mon Mar 17 14:30:59 2014 +0100 @@ -264,9 +264,6 @@ case Byte: prefix = "s8"; break; - case NarrowOop: - prefix = "u32"; - break; default: throw GraalInternalError.shouldNotReachHere(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java --- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Mar 17 14:30:59 2014 +0100 @@ -698,9 +698,6 @@ @Override public void jmp(Label l) { String str = nameOf(l); - if (l.equals("?")) { - Thread.dumpStack(); - } bra(str); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,710 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.baseline; + +import static com.oracle.graal.api.code.TypeCheckHints.*; +import static com.oracle.graal.api.meta.DeoptimizationAction.*; +import static com.oracle.graal.api.meta.DeoptimizationReason.*; +import static com.oracle.graal.bytecode.Bytecodes.*; +import static com.oracle.graal.phases.GraalOptions.*; +import static java.lang.reflect.Modifier.*; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.meta.ProfilingInfo.TriState; +import com.oracle.graal.api.meta.ResolvedJavaType.Representation; +import com.oracle.graal.bytecode.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.java.*; +import com.oracle.graal.java.BciBlockMapping.Block; +import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; +import com.oracle.graal.java.GraphBuilderPhase.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.calc.*; +import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.java.*; +import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; +import com.oracle.graal.nodes.type.*; +import com.oracle.graal.nodes.util.*; +import com.oracle.graal.phases.*; +import com.oracle.graal.phases.tiers.*; + +/** + * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph. + */ +@SuppressWarnings("all") +public class BaselineCompiler { + + public BaselineCompiler(GraphBuilderConfiguration graphBuilderConfig, MetaAccessProvider metaAccess) { + this.graphBuilderConfig = graphBuilderConfig; + this.metaAccess = metaAccess; + } + + private final MetaAccessProvider metaAccess; + private ConstantPool constantPool; + private ResolvedJavaMethod method; + private int entryBCI; + private ProfilingInfo profilingInfo; + private BytecodeStream stream; // the bytecode stream + + private Block currentBlock; + + private ValueNode methodSynchronizedObject; + private ExceptionDispatchBlock unwindBlock; + + private final GraphBuilderConfiguration graphBuilderConfig; + private Block[] loopHeaders; + + /** + * Meters the number of actual bytecodes parsed. + */ + public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed"); + + protected ResolvedJavaMethod getMethod() { + return method; + } + + public LIR generate(ResolvedJavaMethod method, int entryBCI) { + this.method = method; + this.entryBCI = entryBCI; + profilingInfo = method.getProfilingInfo(); + assert method.getCode() != null : "method must contain bytecodes: " + method; + this.stream = new BytecodeStream(method.getCode()); + this.constantPool = method.getConstantPool(); + unwindBlock = null; + methodSynchronizedObject = null; + TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); + try { + build(); + } finally { + filter.remove(); + } + return null; + } + + protected void build() { + if (PrintProfilingInformation.getValue()) { + TTY.println("Profiling info for " + MetaUtil.format("%H.%n(%p)", method)); + TTY.println(MetaUtil.indent(MetaUtil.profileToString(profilingInfo, method, CodeUtil.NEW_LINE), " ")); + } + + Indent indent = Debug.logAndIndent("build graph for %s", method); + + // compute the block map, setup exception handlers and get the entrypoint(s) + BciBlockMapping blockMap = BciBlockMapping.create(method); + loopHeaders = blockMap.loopHeaders; + + if (isSynchronized(method.getModifiers())) { + throw GraalInternalError.unimplemented("Handle synchronized methods"); + } + + // TODO: clear non live locals + + currentBlock = blockMap.startBlock; + if (blockMap.startBlock.isLoopHeader) { + throw GraalInternalError.unimplemented("Handle start block as loop header"); + } + + for (Block block : blockMap.blocks) { + processBlock(block); + } + + indent.outdent(); + } + + public BytecodeStream stream() { + return stream; + } + + public int bci() { + return stream.currentBCI(); + } + + private void loadLocal(int index, Kind kind) { + throw GraalInternalError.unimplemented(); + } + + private void storeLocal(Kind kind, int index) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the unresolved type of the constant + */ + protected void handleUnresolvedLoadConstant(JavaType type) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the unresolved type of the type check + * @param object the object value whose type is being checked against {@code type} + */ + protected void handleUnresolvedCheckCast(JavaType type, ValueNode object) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the unresolved type of the type check + * @param object the object value whose type is being checked against {@code type} + */ + protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the type being instantiated + */ + protected void handleUnresolvedNewInstance(JavaType type) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the type of the array being instantiated + * @param length the length of the array + */ + protected void handleUnresolvedNewObjectArray(JavaType type, ValueNode length) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param type the type being instantiated + * @param dims the dimensions for the multi-array + */ + protected void handleUnresolvedNewMultiArray(JavaType type, ValueNode[] dims) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param field the unresolved field + * @param receiver the object containing the field or {@code null} if {@code field} is static + */ + protected void handleUnresolvedLoadField(JavaField field, ValueNode receiver) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param field the unresolved field + * @param value the value being stored to the field + * @param receiver the object containing the field or {@code null} if {@code field} is static + */ + protected void handleUnresolvedStoreField(JavaField field, ValueNode value, ValueNode receiver) { + throw GraalInternalError.unimplemented(); + } + + /** + * @param representation + * @param type + */ + protected void handleUnresolvedExceptionType(Representation representation, JavaType type) { + throw GraalInternalError.unimplemented(); + } + + protected void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind) { + throw GraalInternalError.unimplemented(); + } + + private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) { + throw GraalInternalError.unimplemented(); + } + + private void genLoadConstant(int cpi, int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genLoadIndexed(Kind kind) { + throw GraalInternalError.unimplemented(); + } + + private void genStoreIndexed(Kind kind) { + throw GraalInternalError.unimplemented(); + } + + private void stackOp(int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genArithmeticOp(Kind result, int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genIntegerDivOp(Kind result, int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genNegateOp(Kind kind) { + throw GraalInternalError.unimplemented(); + } + + private void genShiftOp(Kind kind, int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genLogicOp(Kind kind, int opcode) { + throw GraalInternalError.unimplemented(); + } + + private void genCompareOp(Kind kind, boolean isUnorderedLess) { + throw GraalInternalError.unimplemented(); + } + + private void genFloatConvert(FloatConvert op, Kind from, Kind to) { + throw GraalInternalError.unimplemented(); + } + + private void genSignExtend(Kind from, Kind to) { + throw GraalInternalError.unimplemented(); + } + + private void genZeroExtend(Kind from, Kind to) { + throw GraalInternalError.unimplemented(); + } + + private void genNarrow(Kind from, Kind to) { + throw GraalInternalError.unimplemented(); + } + + private void genIncrement() { + throw GraalInternalError.unimplemented(); + } + + private void genGoto() { + throw GraalInternalError.unimplemented(); + } + + private void genIfZero(Condition cond) { + throw GraalInternalError.unimplemented(); + } + + private void genIfNull(Condition cond) { + throw GraalInternalError.unimplemented(); + } + + private void genIfSame(Kind kind, Condition cond) { + throw GraalInternalError.unimplemented(); + } + + private void genThrow() { + throw GraalInternalError.unimplemented(); + } + + private JavaType lookupType(int cpi, int bytecode) { + eagerResolvingForSnippets(cpi, bytecode); + JavaType result = constantPool.lookupType(cpi, bytecode); + assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaType; + return result; + } + + private JavaMethod lookupMethod(int cpi, int opcode) { + eagerResolvingForSnippets(cpi, opcode); + JavaMethod result = constantPool.lookupMethod(cpi, opcode); + /* + * assert !graphBuilderConfig.unresolvedIsError() || ((result instanceof ResolvedJavaMethod) + * && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result; + */ + return result; + } + + private JavaField lookupField(int cpi, int opcode) { + eagerResolvingForSnippets(cpi, opcode); + JavaField result = constantPool.lookupField(cpi, opcode); + assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result; + return result; + } + + private Object lookupConstant(int cpi, int opcode) { + eagerResolvingForSnippets(cpi, opcode); + Object result = constantPool.lookupConstant(cpi); + assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType); + return result; + } + + private void eagerResolvingForSnippets(int cpi, int bytecode) { + if (graphBuilderConfig.eagerResolving()) { + constantPool.loadReferencedType(cpi, bytecode); + } + } + + private JavaTypeProfile getProfileForTypeCheck(ResolvedJavaType type) { + if (!canHaveSubtype(type)) { + return null; + } else { + return profilingInfo.getTypeProfile(bci()); + } + } + + private void genCheckCast() { + throw GraalInternalError.unimplemented(); + } + + private void genInstanceOf() { + throw GraalInternalError.unimplemented(); + } + + void genNewInstance(int cpi) { + throw GraalInternalError.unimplemented(); + } + + protected NewInstanceNode createNewInstance(ResolvedJavaType type, boolean fillContents) { + return new NewInstanceNode(type, fillContents); + } + + private void genNewPrimitiveArray(int typeCode) { + throw GraalInternalError.unimplemented(); + } + + private void genNewObjectArray(int cpi) { + throw GraalInternalError.unimplemented(); + } + + private void genNewMultiArray(int cpi) { + throw GraalInternalError.unimplemented(); + } + + private void genGetField(JavaField field) { + throw GraalInternalError.unimplemented(); + } + + private void genPutField(JavaField field) { + throw GraalInternalError.unimplemented(); + } + + private void genGetStatic(JavaField field) { + throw GraalInternalError.unimplemented(); + } + + private void genPutStatic(JavaField field) { + throw GraalInternalError.unimplemented(); + } + + private void genInvokeStatic(JavaMethod target) { + throw GraalInternalError.unimplemented(); + } + + private void genInvokeInterface(JavaMethod target) { + throw GraalInternalError.unimplemented(); + } + + private void genInvokeDynamic(JavaMethod target) { + throw GraalInternalError.unimplemented(); + } + + private void genInvokeVirtual(JavaMethod target) { + throw GraalInternalError.unimplemented(); + } + + private void genInvokeSpecial(JavaMethod target) { + throw GraalInternalError.unimplemented(); + } + + private void genJsr(int dest) { + throw GraalInternalError.unimplemented(); + } + + private void genRet(int localIndex) { + throw GraalInternalError.unimplemented(); + } + + private void genSwitch(BytecodeSwitch bs) { + throw GraalInternalError.unimplemented(); + } + + private void processBlock(Block block) { + Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); + currentBlock = block; + iterateBytecodesForBlock(block); + indent.outdent(); + } + + private void createExceptionDispatch(ExceptionDispatchBlock block) { + throw GraalInternalError.unimplemented(); + } + + private void iterateBytecodesForBlock(Block block) { + + int endBCI = stream.endBCI(); + + stream.setBCI(block.startBci); + int bci = block.startBci; + BytecodesParsed.add(block.endBci - bci); + + while (bci < endBCI) { + + // read the opcode + int opcode = stream.currentBC(); + traceInstruction(bci, opcode, bci == block.startBci); + if (bci == entryBCI) { + throw GraalInternalError.unimplemented(); + } + processBytecode(bci, opcode); + + stream.next(); + bci = stream.currentBCI(); + } + } + + private void processBytecode(int bci, int opcode) { + int cpi; + + // Checkstyle: stop + // @formatter:off + switch (opcode) { + case NOP : /* nothing to do */ break; +// case ACONST_NULL : frameState.apush(appendConstant(Constant.NULL_OBJECT)); break; +// case ICONST_M1 : frameState.ipush(appendConstant(Constant.INT_MINUS_1)); break; +// case ICONST_0 : frameState.ipush(appendConstant(Constant.INT_0)); break; +// case ICONST_1 : frameState.ipush(appendConstant(Constant.INT_1)); break; +// case ICONST_2 : frameState.ipush(appendConstant(Constant.INT_2)); break; +// case ICONST_3 : frameState.ipush(appendConstant(Constant.INT_3)); break; +// case ICONST_4 : frameState.ipush(appendConstant(Constant.INT_4)); break; +// case ICONST_5 : frameState.ipush(appendConstant(Constant.INT_5)); break; +// case LCONST_0 : frameState.lpush(appendConstant(Constant.LONG_0)); break; +// case LCONST_1 : frameState.lpush(appendConstant(Constant.LONG_1)); break; +// case FCONST_0 : frameState.fpush(appendConstant(Constant.FLOAT_0)); break; +// case FCONST_1 : frameState.fpush(appendConstant(Constant.FLOAT_1)); break; +// case FCONST_2 : frameState.fpush(appendConstant(Constant.FLOAT_2)); break; +// case DCONST_0 : frameState.dpush(appendConstant(Constant.DOUBLE_0)); break; +// case DCONST_1 : frameState.dpush(appendConstant(Constant.DOUBLE_1)); break; +// case BIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readByte()))); break; +// case SIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readShort()))); break; + case LDC : // fall through + case LDC_W : // fall through + case LDC2_W : genLoadConstant(stream.readCPI(), opcode); break; + case ILOAD : loadLocal(stream.readLocalIndex(), Kind.Int); break; + case LLOAD : loadLocal(stream.readLocalIndex(), Kind.Long); break; + case FLOAD : loadLocal(stream.readLocalIndex(), Kind.Float); break; + case DLOAD : loadLocal(stream.readLocalIndex(), Kind.Double); break; + case ALOAD : loadLocal(stream.readLocalIndex(), Kind.Object); break; + case ILOAD_0 : // fall through + case ILOAD_1 : // fall through + case ILOAD_2 : // fall through + case ILOAD_3 : loadLocal(opcode - ILOAD_0, Kind.Int); break; + case LLOAD_0 : // fall through + case LLOAD_1 : // fall through + case LLOAD_2 : // fall through + case LLOAD_3 : loadLocal(opcode - LLOAD_0, Kind.Long); break; + case FLOAD_0 : // fall through + case FLOAD_1 : // fall through + case FLOAD_2 : // fall through + case FLOAD_3 : loadLocal(opcode - FLOAD_0, Kind.Float); break; + case DLOAD_0 : // fall through + case DLOAD_1 : // fall through + case DLOAD_2 : // fall through + case DLOAD_3 : loadLocal(opcode - DLOAD_0, Kind.Double); break; + case ALOAD_0 : // fall through + case ALOAD_1 : // fall through + case ALOAD_2 : // fall through + case ALOAD_3 : loadLocal(opcode - ALOAD_0, Kind.Object); break; + case IALOAD : genLoadIndexed(Kind.Int ); break; + case LALOAD : genLoadIndexed(Kind.Long ); break; + case FALOAD : genLoadIndexed(Kind.Float ); break; + case DALOAD : genLoadIndexed(Kind.Double); break; + case AALOAD : genLoadIndexed(Kind.Object); break; + case BALOAD : genLoadIndexed(Kind.Byte ); break; + case CALOAD : genLoadIndexed(Kind.Char ); break; + case SALOAD : genLoadIndexed(Kind.Short ); break; + case ISTORE : storeLocal(Kind.Int, stream.readLocalIndex()); break; + case LSTORE : storeLocal(Kind.Long, stream.readLocalIndex()); break; + case FSTORE : storeLocal(Kind.Float, stream.readLocalIndex()); break; + case DSTORE : storeLocal(Kind.Double, stream.readLocalIndex()); break; + case ASTORE : storeLocal(Kind.Object, stream.readLocalIndex()); break; + case ISTORE_0 : // fall through + case ISTORE_1 : // fall through + case ISTORE_2 : // fall through + case ISTORE_3 : storeLocal(Kind.Int, opcode - ISTORE_0); break; + case LSTORE_0 : // fall through + case LSTORE_1 : // fall through + case LSTORE_2 : // fall through + case LSTORE_3 : storeLocal(Kind.Long, opcode - LSTORE_0); break; + case FSTORE_0 : // fall through + case FSTORE_1 : // fall through + case FSTORE_2 : // fall through + case FSTORE_3 : storeLocal(Kind.Float, opcode - FSTORE_0); break; + case DSTORE_0 : // fall through + case DSTORE_1 : // fall through + case DSTORE_2 : // fall through + case DSTORE_3 : storeLocal(Kind.Double, opcode - DSTORE_0); break; + case ASTORE_0 : // fall through + case ASTORE_1 : // fall through + case ASTORE_2 : // fall through + case ASTORE_3 : storeLocal(Kind.Object, opcode - ASTORE_0); break; + case IASTORE : genStoreIndexed(Kind.Int ); break; + case LASTORE : genStoreIndexed(Kind.Long ); break; + case FASTORE : genStoreIndexed(Kind.Float ); break; + case DASTORE : genStoreIndexed(Kind.Double); break; + case AASTORE : genStoreIndexed(Kind.Object); break; + case BASTORE : genStoreIndexed(Kind.Byte ); break; + case CASTORE : genStoreIndexed(Kind.Char ); break; + case SASTORE : genStoreIndexed(Kind.Short ); break; + case POP : // fall through + case POP2 : // fall through + case DUP : // fall through + case DUP_X1 : // fall through + case DUP_X2 : // fall through + case DUP2 : // fall through + case DUP2_X1 : // fall through + case DUP2_X2 : // fall through + case SWAP : stackOp(opcode); break; + case IADD : // fall through + case ISUB : // fall through + case IMUL : genArithmeticOp(Kind.Int, opcode); break; + case IDIV : // fall through + case IREM : genIntegerDivOp(Kind.Int, opcode); break; + case LADD : // fall through + case LSUB : // fall through + case LMUL : genArithmeticOp(Kind.Long, opcode); break; + case LDIV : // fall through + case LREM : genIntegerDivOp(Kind.Long, opcode); break; + case FADD : // fall through + case FSUB : // fall through + case FMUL : // fall through + case FDIV : // fall through + case FREM : genArithmeticOp(Kind.Float, opcode); break; + case DADD : // fall through + case DSUB : // fall through + case DMUL : // fall through + case DDIV : // fall through + case DREM : genArithmeticOp(Kind.Double, opcode); break; + case INEG : genNegateOp(Kind.Int); break; + case LNEG : genNegateOp(Kind.Long); break; + case FNEG : genNegateOp(Kind.Float); break; + case DNEG : genNegateOp(Kind.Double); break; + case ISHL : // fall through + case ISHR : // fall through + case IUSHR : genShiftOp(Kind.Int, opcode); break; + case IAND : // fall through + case IOR : // fall through + case IXOR : genLogicOp(Kind.Int, opcode); break; + case LSHL : // fall through + case LSHR : // fall through + case LUSHR : genShiftOp(Kind.Long, opcode); break; + case LAND : // fall through + case LOR : // fall through + case LXOR : genLogicOp(Kind.Long, opcode); break; + case IINC : genIncrement(); break; + case I2F : genFloatConvert(FloatConvert.I2F, Kind.Int, Kind.Float); break; + case I2D : genFloatConvert(FloatConvert.I2D, Kind.Int, Kind.Double); break; + case L2F : genFloatConvert(FloatConvert.L2F, Kind.Long, Kind.Float); break; + case L2D : genFloatConvert(FloatConvert.L2D, Kind.Long, Kind.Double); break; + case F2I : genFloatConvert(FloatConvert.F2I, Kind.Float, Kind.Int); break; + case F2L : genFloatConvert(FloatConvert.F2L, Kind.Float, Kind.Long); break; + case F2D : genFloatConvert(FloatConvert.F2D, Kind.Float, Kind.Double); break; + case D2I : genFloatConvert(FloatConvert.D2I, Kind.Double, Kind.Int); break; + case D2L : genFloatConvert(FloatConvert.D2L, Kind.Double, Kind.Long); break; + case D2F : genFloatConvert(FloatConvert.D2F, Kind.Double, Kind.Float); break; + case L2I : genNarrow(Kind.Long, Kind.Int); break; + case I2L : genSignExtend(Kind.Int, Kind.Long); break; + case I2B : genSignExtend(Kind.Byte, Kind.Int); break; + case I2S : genSignExtend(Kind.Short, Kind.Int); break; + case I2C : genZeroExtend(Kind.Char, Kind.Int); break; + case LCMP : genCompareOp(Kind.Long, false); break; + case FCMPL : genCompareOp(Kind.Float, true); break; + case FCMPG : genCompareOp(Kind.Float, false); break; + case DCMPL : genCompareOp(Kind.Double, true); break; + case DCMPG : genCompareOp(Kind.Double, false); break; + case IFEQ : genIfZero(Condition.EQ); break; + case IFNE : genIfZero(Condition.NE); break; + case IFLT : genIfZero(Condition.LT); break; + case IFGE : genIfZero(Condition.GE); break; + case IFGT : genIfZero(Condition.GT); break; + case IFLE : genIfZero(Condition.LE); break; + case IF_ICMPEQ : genIfSame(Kind.Int, Condition.EQ); break; + case IF_ICMPNE : genIfSame(Kind.Int, Condition.NE); break; + case IF_ICMPLT : genIfSame(Kind.Int, Condition.LT); break; + case IF_ICMPGE : genIfSame(Kind.Int, Condition.GE); break; + case IF_ICMPGT : genIfSame(Kind.Int, Condition.GT); break; + case IF_ICMPLE : genIfSame(Kind.Int, Condition.LE); break; + case IF_ACMPEQ : genIfSame(Kind.Object, Condition.EQ); break; + case IF_ACMPNE : genIfSame(Kind.Object, Condition.NE); break; + case GOTO : genGoto(); break; + case JSR : genJsr(stream.readBranchDest()); break; + case RET : genRet(stream.readLocalIndex()); break; + case TABLESWITCH : genSwitch(new BytecodeTableSwitch(stream(), bci())); break; + case LOOKUPSWITCH : genSwitch(new BytecodeLookupSwitch(stream(), bci())); break; +// case IRETURN : genReturn(frameState.ipop()); break; +// case LRETURN : genReturn(frameState.lpop()); break; +// case FRETURN : genReturn(frameState.fpop()); break; +// case DRETURN : genReturn(frameState.dpop()); break; +// case ARETURN : genReturn(frameState.apop()); break; +// case RETURN : genReturn(null); break; + case GETSTATIC : cpi = stream.readCPI(); genGetStatic(lookupField(cpi, opcode)); break; + case PUTSTATIC : cpi = stream.readCPI(); genPutStatic(lookupField(cpi, opcode)); break; + case GETFIELD : cpi = stream.readCPI(); genGetField(lookupField(cpi, opcode)); break; + case PUTFIELD : cpi = stream.readCPI(); genPutField(lookupField(cpi, opcode)); break; + case INVOKEVIRTUAL : cpi = stream.readCPI(); genInvokeVirtual(lookupMethod(cpi, opcode)); break; + case INVOKESPECIAL : cpi = stream.readCPI(); genInvokeSpecial(lookupMethod(cpi, opcode)); break; + case INVOKESTATIC : cpi = stream.readCPI(); genInvokeStatic(lookupMethod(cpi, opcode)); break; + case INVOKEINTERFACE: cpi = stream.readCPI(); genInvokeInterface(lookupMethod(cpi, opcode)); break; + case INVOKEDYNAMIC : cpi = stream.readCPI4(); genInvokeDynamic(lookupMethod(cpi, opcode)); break; + case NEW : genNewInstance(stream.readCPI()); break; + case NEWARRAY : genNewPrimitiveArray(stream.readLocalIndex()); break; + case ANEWARRAY : genNewObjectArray(stream.readCPI()); break; + case ARRAYLENGTH : genArrayLength(); break; + case ATHROW : genThrow(); break; + case CHECKCAST : genCheckCast(); break; + case INSTANCEOF : genInstanceOf(); break; +// case MONITORENTER : genMonitorEnter(frameState.apop()); break; +// case MONITOREXIT : genMonitorExit(frameState.apop(), null); break; + case MULTIANEWARRAY : genNewMultiArray(stream.readCPI()); break; + case IFNULL : genIfNull(Condition.EQ); break; + case IFNONNULL : genIfNull(Condition.NE); break; + case GOTO_W : genGoto(); break; + case JSR_W : genJsr(stream.readBranchDest()); break; + case BREAKPOINT: + throw new BailoutException("concurrent setting of breakpoint"); + default: + throw new BailoutException("Unsupported opcode " + opcode + " (" + nameOf(opcode) + ") [bci=" + bci + "]"); + } + // @formatter:on + // Checkstyle: resume + } + + private void traceInstruction(int bci, int opcode, boolean blockStart) { + if (Debug.isLogEnabled()) { + StringBuilder sb = new StringBuilder(40); + sb.append(blockStart ? '+' : '|'); + if (bci < 10) { + sb.append(" "); + } else if (bci < 100) { + sb.append(' '); + } + sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode)); + for (int i = bci + 1; i < stream.nextBCI(); ++i) { + sb.append(' ').append(stream.readUByte(i)); + } + if (!currentBlock.jsrScope.isEmpty()) { + sb.append(' ').append(currentBlock.jsrScope); + } + Debug.log(sb.toString()); + } + } + + private void genArrayLength() { + throw GraalInternalError.unimplemented(); + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaslineCompiler.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaslineCompiler.java Mon Mar 17 14:29:45 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,710 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.baseline; - -import static com.oracle.graal.api.code.TypeCheckHints.*; -import static com.oracle.graal.api.meta.DeoptimizationAction.*; -import static com.oracle.graal.api.meta.DeoptimizationReason.*; -import static com.oracle.graal.bytecode.Bytecodes.*; -import static com.oracle.graal.phases.GraalOptions.*; -import static java.lang.reflect.Modifier.*; - -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ProfilingInfo.TriState; -import com.oracle.graal.api.meta.ResolvedJavaType.Representation; -import com.oracle.graal.bytecode.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.java.*; -import com.oracle.graal.java.BciBlockMapping.Block; -import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; -import com.oracle.graal.java.GraphBuilderPhase.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.java.*; -import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; -import com.oracle.graal.nodes.type.*; -import com.oracle.graal.nodes.util.*; -import com.oracle.graal.phases.*; -import com.oracle.graal.phases.tiers.*; - -/** - * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph. - */ -@SuppressWarnings("all") -public class BaslineCompiler { - - public BaslineCompiler(GraphBuilderConfiguration graphBuilderConfig, MetaAccessProvider metaAccess) { - this.graphBuilderConfig = graphBuilderConfig; - this.metaAccess = metaAccess; - } - - private final MetaAccessProvider metaAccess; - private ConstantPool constantPool; - private ResolvedJavaMethod method; - private int entryBCI; - private ProfilingInfo profilingInfo; - private BytecodeStream stream; // the bytecode stream - - private Block currentBlock; - - private ValueNode methodSynchronizedObject; - private ExceptionDispatchBlock unwindBlock; - - private final GraphBuilderConfiguration graphBuilderConfig; - private Block[] loopHeaders; - - /** - * Meters the number of actual bytecodes parsed. - */ - public static final DebugMetric BytecodesParsed = Debug.metric("BytecodesParsed"); - - protected ResolvedJavaMethod getMethod() { - return method; - } - - public LIR generate(ResolvedJavaMethod method, int entryBCI) { - this.method = method; - this.entryBCI = entryBCI; - profilingInfo = method.getProfilingInfo(); - assert method.getCode() != null : "method must contain bytecodes: " + method; - this.stream = new BytecodeStream(method.getCode()); - this.constantPool = method.getConstantPool(); - unwindBlock = null; - methodSynchronizedObject = null; - TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); - try { - build(); - } finally { - filter.remove(); - } - return null; - } - - protected void build() { - if (PrintProfilingInformation.getValue()) { - TTY.println("Profiling info for " + MetaUtil.format("%H.%n(%p)", method)); - TTY.println(MetaUtil.indent(MetaUtil.profileToString(profilingInfo, method, CodeUtil.NEW_LINE), " ")); - } - - Indent indent = Debug.logAndIndent("build graph for %s", method); - - // compute the block map, setup exception handlers and get the entrypoint(s) - BciBlockMapping blockMap = BciBlockMapping.create(method); - loopHeaders = blockMap.loopHeaders; - - if (isSynchronized(method.getModifiers())) { - throw GraalInternalError.unimplemented("Handle synchronized methods"); - } - - // TODO: clear non live locals - - currentBlock = blockMap.startBlock; - if (blockMap.startBlock.isLoopHeader) { - throw GraalInternalError.unimplemented("Handle start block as loop header"); - } - - for (Block block : blockMap.blocks) { - processBlock(block); - } - - indent.outdent(); - } - - public BytecodeStream stream() { - return stream; - } - - public int bci() { - return stream.currentBCI(); - } - - private void loadLocal(int index, Kind kind) { - throw GraalInternalError.unimplemented(); - } - - private void storeLocal(Kind kind, int index) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the unresolved type of the constant - */ - protected void handleUnresolvedLoadConstant(JavaType type) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the unresolved type of the type check - * @param object the object value whose type is being checked against {@code type} - */ - protected void handleUnresolvedCheckCast(JavaType type, ValueNode object) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the unresolved type of the type check - * @param object the object value whose type is being checked against {@code type} - */ - protected void handleUnresolvedInstanceOf(JavaType type, ValueNode object) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the type being instantiated - */ - protected void handleUnresolvedNewInstance(JavaType type) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the type of the array being instantiated - * @param length the length of the array - */ - protected void handleUnresolvedNewObjectArray(JavaType type, ValueNode length) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param type the type being instantiated - * @param dims the dimensions for the multi-array - */ - protected void handleUnresolvedNewMultiArray(JavaType type, ValueNode[] dims) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param field the unresolved field - * @param receiver the object containing the field or {@code null} if {@code field} is static - */ - protected void handleUnresolvedLoadField(JavaField field, ValueNode receiver) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param field the unresolved field - * @param value the value being stored to the field - * @param receiver the object containing the field or {@code null} if {@code field} is static - */ - protected void handleUnresolvedStoreField(JavaField field, ValueNode value, ValueNode receiver) { - throw GraalInternalError.unimplemented(); - } - - /** - * @param representation - * @param type - */ - protected void handleUnresolvedExceptionType(Representation representation, JavaType type) { - throw GraalInternalError.unimplemented(); - } - - protected void handleUnresolvedInvoke(JavaMethod javaMethod, InvokeKind invokeKind) { - throw GraalInternalError.unimplemented(); - } - - private DispatchBeginNode handleException(ValueNode exceptionObject, int bci) { - throw GraalInternalError.unimplemented(); - } - - private void genLoadConstant(int cpi, int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genLoadIndexed(Kind kind) { - throw GraalInternalError.unimplemented(); - } - - private void genStoreIndexed(Kind kind) { - throw GraalInternalError.unimplemented(); - } - - private void stackOp(int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genArithmeticOp(Kind result, int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genIntegerDivOp(Kind result, int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genNegateOp(Kind kind) { - throw GraalInternalError.unimplemented(); - } - - private void genShiftOp(Kind kind, int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genLogicOp(Kind kind, int opcode) { - throw GraalInternalError.unimplemented(); - } - - private void genCompareOp(Kind kind, boolean isUnorderedLess) { - throw GraalInternalError.unimplemented(); - } - - private void genFloatConvert(FloatConvert op, Kind from, Kind to) { - throw GraalInternalError.unimplemented(); - } - - private void genSignExtend(Kind from, Kind to) { - throw GraalInternalError.unimplemented(); - } - - private void genZeroExtend(Kind from, Kind to) { - throw GraalInternalError.unimplemented(); - } - - private void genNarrow(Kind from, Kind to) { - throw GraalInternalError.unimplemented(); - } - - private void genIncrement() { - throw GraalInternalError.unimplemented(); - } - - private void genGoto() { - throw GraalInternalError.unimplemented(); - } - - private void genIfZero(Condition cond) { - throw GraalInternalError.unimplemented(); - } - - private void genIfNull(Condition cond) { - throw GraalInternalError.unimplemented(); - } - - private void genIfSame(Kind kind, Condition cond) { - throw GraalInternalError.unimplemented(); - } - - private void genThrow() { - throw GraalInternalError.unimplemented(); - } - - private JavaType lookupType(int cpi, int bytecode) { - eagerResolvingForSnippets(cpi, bytecode); - JavaType result = constantPool.lookupType(cpi, bytecode); - assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaType; - return result; - } - - private JavaMethod lookupMethod(int cpi, int opcode) { - eagerResolvingForSnippets(cpi, opcode); - JavaMethod result = constantPool.lookupMethod(cpi, opcode); - /* - * assert !graphBuilderConfig.unresolvedIsError() || ((result instanceof ResolvedJavaMethod) - * && ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized()) : result; - */ - return result; - } - - private JavaField lookupField(int cpi, int opcode) { - eagerResolvingForSnippets(cpi, opcode); - JavaField result = constantPool.lookupField(cpi, opcode); - assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaField && ((ResolvedJavaField) result).getDeclaringClass().isInitialized()) : result; - return result; - } - - private Object lookupConstant(int cpi, int opcode) { - eagerResolvingForSnippets(cpi, opcode); - Object result = constantPool.lookupConstant(cpi); - assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType); - return result; - } - - private void eagerResolvingForSnippets(int cpi, int bytecode) { - if (graphBuilderConfig.eagerResolving()) { - constantPool.loadReferencedType(cpi, bytecode); - } - } - - private JavaTypeProfile getProfileForTypeCheck(ResolvedJavaType type) { - if (!canHaveSubtype(type)) { - return null; - } else { - return profilingInfo.getTypeProfile(bci()); - } - } - - private void genCheckCast() { - throw GraalInternalError.unimplemented(); - } - - private void genInstanceOf() { - throw GraalInternalError.unimplemented(); - } - - void genNewInstance(int cpi) { - throw GraalInternalError.unimplemented(); - } - - protected NewInstanceNode createNewInstance(ResolvedJavaType type, boolean fillContents) { - return new NewInstanceNode(type, fillContents); - } - - private void genNewPrimitiveArray(int typeCode) { - throw GraalInternalError.unimplemented(); - } - - private void genNewObjectArray(int cpi) { - throw GraalInternalError.unimplemented(); - } - - private void genNewMultiArray(int cpi) { - throw GraalInternalError.unimplemented(); - } - - private void genGetField(JavaField field) { - throw GraalInternalError.unimplemented(); - } - - private void genPutField(JavaField field) { - throw GraalInternalError.unimplemented(); - } - - private void genGetStatic(JavaField field) { - throw GraalInternalError.unimplemented(); - } - - private void genPutStatic(JavaField field) { - throw GraalInternalError.unimplemented(); - } - - private void genInvokeStatic(JavaMethod target) { - throw GraalInternalError.unimplemented(); - } - - private void genInvokeInterface(JavaMethod target) { - throw GraalInternalError.unimplemented(); - } - - private void genInvokeDynamic(JavaMethod target) { - throw GraalInternalError.unimplemented(); - } - - private void genInvokeVirtual(JavaMethod target) { - throw GraalInternalError.unimplemented(); - } - - private void genInvokeSpecial(JavaMethod target) { - throw GraalInternalError.unimplemented(); - } - - private void genJsr(int dest) { - throw GraalInternalError.unimplemented(); - } - - private void genRet(int localIndex) { - throw GraalInternalError.unimplemented(); - } - - private void genSwitch(BytecodeSwitch bs) { - throw GraalInternalError.unimplemented(); - } - - private void processBlock(Block block) { - Indent indent = Debug.logAndIndent("Parsing block %s firstInstruction: %s loopHeader: %b", block, block.firstInstruction, block.isLoopHeader); - currentBlock = block; - iterateBytecodesForBlock(block); - indent.outdent(); - } - - private void createExceptionDispatch(ExceptionDispatchBlock block) { - throw GraalInternalError.unimplemented(); - } - - private void iterateBytecodesForBlock(Block block) { - - int endBCI = stream.endBCI(); - - stream.setBCI(block.startBci); - int bci = block.startBci; - BytecodesParsed.add(block.endBci - bci); - - while (bci < endBCI) { - - // read the opcode - int opcode = stream.currentBC(); - traceInstruction(bci, opcode, bci == block.startBci); - if (bci == entryBCI) { - throw GraalInternalError.unimplemented(); - } - processBytecode(bci, opcode); - - stream.next(); - bci = stream.currentBCI(); - } - } - - private void processBytecode(int bci, int opcode) { - int cpi; - - // Checkstyle: stop - // @formatter:off - switch (opcode) { - case NOP : /* nothing to do */ break; -// case ACONST_NULL : frameState.apush(appendConstant(Constant.NULL_OBJECT)); break; -// case ICONST_M1 : frameState.ipush(appendConstant(Constant.INT_MINUS_1)); break; -// case ICONST_0 : frameState.ipush(appendConstant(Constant.INT_0)); break; -// case ICONST_1 : frameState.ipush(appendConstant(Constant.INT_1)); break; -// case ICONST_2 : frameState.ipush(appendConstant(Constant.INT_2)); break; -// case ICONST_3 : frameState.ipush(appendConstant(Constant.INT_3)); break; -// case ICONST_4 : frameState.ipush(appendConstant(Constant.INT_4)); break; -// case ICONST_5 : frameState.ipush(appendConstant(Constant.INT_5)); break; -// case LCONST_0 : frameState.lpush(appendConstant(Constant.LONG_0)); break; -// case LCONST_1 : frameState.lpush(appendConstant(Constant.LONG_1)); break; -// case FCONST_0 : frameState.fpush(appendConstant(Constant.FLOAT_0)); break; -// case FCONST_1 : frameState.fpush(appendConstant(Constant.FLOAT_1)); break; -// case FCONST_2 : frameState.fpush(appendConstant(Constant.FLOAT_2)); break; -// case DCONST_0 : frameState.dpush(appendConstant(Constant.DOUBLE_0)); break; -// case DCONST_1 : frameState.dpush(appendConstant(Constant.DOUBLE_1)); break; -// case BIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readByte()))); break; -// case SIPUSH : frameState.ipush(appendConstant(Constant.forInt(stream.readShort()))); break; - case LDC : // fall through - case LDC_W : // fall through - case LDC2_W : genLoadConstant(stream.readCPI(), opcode); break; - case ILOAD : loadLocal(stream.readLocalIndex(), Kind.Int); break; - case LLOAD : loadLocal(stream.readLocalIndex(), Kind.Long); break; - case FLOAD : loadLocal(stream.readLocalIndex(), Kind.Float); break; - case DLOAD : loadLocal(stream.readLocalIndex(), Kind.Double); break; - case ALOAD : loadLocal(stream.readLocalIndex(), Kind.Object); break; - case ILOAD_0 : // fall through - case ILOAD_1 : // fall through - case ILOAD_2 : // fall through - case ILOAD_3 : loadLocal(opcode - ILOAD_0, Kind.Int); break; - case LLOAD_0 : // fall through - case LLOAD_1 : // fall through - case LLOAD_2 : // fall through - case LLOAD_3 : loadLocal(opcode - LLOAD_0, Kind.Long); break; - case FLOAD_0 : // fall through - case FLOAD_1 : // fall through - case FLOAD_2 : // fall through - case FLOAD_3 : loadLocal(opcode - FLOAD_0, Kind.Float); break; - case DLOAD_0 : // fall through - case DLOAD_1 : // fall through - case DLOAD_2 : // fall through - case DLOAD_3 : loadLocal(opcode - DLOAD_0, Kind.Double); break; - case ALOAD_0 : // fall through - case ALOAD_1 : // fall through - case ALOAD_2 : // fall through - case ALOAD_3 : loadLocal(opcode - ALOAD_0, Kind.Object); break; - case IALOAD : genLoadIndexed(Kind.Int ); break; - case LALOAD : genLoadIndexed(Kind.Long ); break; - case FALOAD : genLoadIndexed(Kind.Float ); break; - case DALOAD : genLoadIndexed(Kind.Double); break; - case AALOAD : genLoadIndexed(Kind.Object); break; - case BALOAD : genLoadIndexed(Kind.Byte ); break; - case CALOAD : genLoadIndexed(Kind.Char ); break; - case SALOAD : genLoadIndexed(Kind.Short ); break; - case ISTORE : storeLocal(Kind.Int, stream.readLocalIndex()); break; - case LSTORE : storeLocal(Kind.Long, stream.readLocalIndex()); break; - case FSTORE : storeLocal(Kind.Float, stream.readLocalIndex()); break; - case DSTORE : storeLocal(Kind.Double, stream.readLocalIndex()); break; - case ASTORE : storeLocal(Kind.Object, stream.readLocalIndex()); break; - case ISTORE_0 : // fall through - case ISTORE_1 : // fall through - case ISTORE_2 : // fall through - case ISTORE_3 : storeLocal(Kind.Int, opcode - ISTORE_0); break; - case LSTORE_0 : // fall through - case LSTORE_1 : // fall through - case LSTORE_2 : // fall through - case LSTORE_3 : storeLocal(Kind.Long, opcode - LSTORE_0); break; - case FSTORE_0 : // fall through - case FSTORE_1 : // fall through - case FSTORE_2 : // fall through - case FSTORE_3 : storeLocal(Kind.Float, opcode - FSTORE_0); break; - case DSTORE_0 : // fall through - case DSTORE_1 : // fall through - case DSTORE_2 : // fall through - case DSTORE_3 : storeLocal(Kind.Double, opcode - DSTORE_0); break; - case ASTORE_0 : // fall through - case ASTORE_1 : // fall through - case ASTORE_2 : // fall through - case ASTORE_3 : storeLocal(Kind.Object, opcode - ASTORE_0); break; - case IASTORE : genStoreIndexed(Kind.Int ); break; - case LASTORE : genStoreIndexed(Kind.Long ); break; - case FASTORE : genStoreIndexed(Kind.Float ); break; - case DASTORE : genStoreIndexed(Kind.Double); break; - case AASTORE : genStoreIndexed(Kind.Object); break; - case BASTORE : genStoreIndexed(Kind.Byte ); break; - case CASTORE : genStoreIndexed(Kind.Char ); break; - case SASTORE : genStoreIndexed(Kind.Short ); break; - case POP : // fall through - case POP2 : // fall through - case DUP : // fall through - case DUP_X1 : // fall through - case DUP_X2 : // fall through - case DUP2 : // fall through - case DUP2_X1 : // fall through - case DUP2_X2 : // fall through - case SWAP : stackOp(opcode); break; - case IADD : // fall through - case ISUB : // fall through - case IMUL : genArithmeticOp(Kind.Int, opcode); break; - case IDIV : // fall through - case IREM : genIntegerDivOp(Kind.Int, opcode); break; - case LADD : // fall through - case LSUB : // fall through - case LMUL : genArithmeticOp(Kind.Long, opcode); break; - case LDIV : // fall through - case LREM : genIntegerDivOp(Kind.Long, opcode); break; - case FADD : // fall through - case FSUB : // fall through - case FMUL : // fall through - case FDIV : // fall through - case FREM : genArithmeticOp(Kind.Float, opcode); break; - case DADD : // fall through - case DSUB : // fall through - case DMUL : // fall through - case DDIV : // fall through - case DREM : genArithmeticOp(Kind.Double, opcode); break; - case INEG : genNegateOp(Kind.Int); break; - case LNEG : genNegateOp(Kind.Long); break; - case FNEG : genNegateOp(Kind.Float); break; - case DNEG : genNegateOp(Kind.Double); break; - case ISHL : // fall through - case ISHR : // fall through - case IUSHR : genShiftOp(Kind.Int, opcode); break; - case IAND : // fall through - case IOR : // fall through - case IXOR : genLogicOp(Kind.Int, opcode); break; - case LSHL : // fall through - case LSHR : // fall through - case LUSHR : genShiftOp(Kind.Long, opcode); break; - case LAND : // fall through - case LOR : // fall through - case LXOR : genLogicOp(Kind.Long, opcode); break; - case IINC : genIncrement(); break; - case I2F : genFloatConvert(FloatConvert.I2F, Kind.Int, Kind.Float); break; - case I2D : genFloatConvert(FloatConvert.I2D, Kind.Int, Kind.Double); break; - case L2F : genFloatConvert(FloatConvert.L2F, Kind.Long, Kind.Float); break; - case L2D : genFloatConvert(FloatConvert.L2D, Kind.Long, Kind.Double); break; - case F2I : genFloatConvert(FloatConvert.F2I, Kind.Float, Kind.Int); break; - case F2L : genFloatConvert(FloatConvert.F2L, Kind.Float, Kind.Long); break; - case F2D : genFloatConvert(FloatConvert.F2D, Kind.Float, Kind.Double); break; - case D2I : genFloatConvert(FloatConvert.D2I, Kind.Double, Kind.Int); break; - case D2L : genFloatConvert(FloatConvert.D2L, Kind.Double, Kind.Long); break; - case D2F : genFloatConvert(FloatConvert.D2F, Kind.Double, Kind.Float); break; - case L2I : genNarrow(Kind.Long, Kind.Int); break; - case I2L : genSignExtend(Kind.Int, Kind.Long); break; - case I2B : genSignExtend(Kind.Byte, Kind.Int); break; - case I2S : genSignExtend(Kind.Short, Kind.Int); break; - case I2C : genZeroExtend(Kind.Char, Kind.Int); break; - case LCMP : genCompareOp(Kind.Long, false); break; - case FCMPL : genCompareOp(Kind.Float, true); break; - case FCMPG : genCompareOp(Kind.Float, false); break; - case DCMPL : genCompareOp(Kind.Double, true); break; - case DCMPG : genCompareOp(Kind.Double, false); break; - case IFEQ : genIfZero(Condition.EQ); break; - case IFNE : genIfZero(Condition.NE); break; - case IFLT : genIfZero(Condition.LT); break; - case IFGE : genIfZero(Condition.GE); break; - case IFGT : genIfZero(Condition.GT); break; - case IFLE : genIfZero(Condition.LE); break; - case IF_ICMPEQ : genIfSame(Kind.Int, Condition.EQ); break; - case IF_ICMPNE : genIfSame(Kind.Int, Condition.NE); break; - case IF_ICMPLT : genIfSame(Kind.Int, Condition.LT); break; - case IF_ICMPGE : genIfSame(Kind.Int, Condition.GE); break; - case IF_ICMPGT : genIfSame(Kind.Int, Condition.GT); break; - case IF_ICMPLE : genIfSame(Kind.Int, Condition.LE); break; - case IF_ACMPEQ : genIfSame(Kind.Object, Condition.EQ); break; - case IF_ACMPNE : genIfSame(Kind.Object, Condition.NE); break; - case GOTO : genGoto(); break; - case JSR : genJsr(stream.readBranchDest()); break; - case RET : genRet(stream.readLocalIndex()); break; - case TABLESWITCH : genSwitch(new BytecodeTableSwitch(stream(), bci())); break; - case LOOKUPSWITCH : genSwitch(new BytecodeLookupSwitch(stream(), bci())); break; -// case IRETURN : genReturn(frameState.ipop()); break; -// case LRETURN : genReturn(frameState.lpop()); break; -// case FRETURN : genReturn(frameState.fpop()); break; -// case DRETURN : genReturn(frameState.dpop()); break; -// case ARETURN : genReturn(frameState.apop()); break; -// case RETURN : genReturn(null); break; - case GETSTATIC : cpi = stream.readCPI(); genGetStatic(lookupField(cpi, opcode)); break; - case PUTSTATIC : cpi = stream.readCPI(); genPutStatic(lookupField(cpi, opcode)); break; - case GETFIELD : cpi = stream.readCPI(); genGetField(lookupField(cpi, opcode)); break; - case PUTFIELD : cpi = stream.readCPI(); genPutField(lookupField(cpi, opcode)); break; - case INVOKEVIRTUAL : cpi = stream.readCPI(); genInvokeVirtual(lookupMethod(cpi, opcode)); break; - case INVOKESPECIAL : cpi = stream.readCPI(); genInvokeSpecial(lookupMethod(cpi, opcode)); break; - case INVOKESTATIC : cpi = stream.readCPI(); genInvokeStatic(lookupMethod(cpi, opcode)); break; - case INVOKEINTERFACE: cpi = stream.readCPI(); genInvokeInterface(lookupMethod(cpi, opcode)); break; - case INVOKEDYNAMIC : cpi = stream.readCPI4(); genInvokeDynamic(lookupMethod(cpi, opcode)); break; - case NEW : genNewInstance(stream.readCPI()); break; - case NEWARRAY : genNewPrimitiveArray(stream.readLocalIndex()); break; - case ANEWARRAY : genNewObjectArray(stream.readCPI()); break; - case ARRAYLENGTH : genArrayLength(); break; - case ATHROW : genThrow(); break; - case CHECKCAST : genCheckCast(); break; - case INSTANCEOF : genInstanceOf(); break; -// case MONITORENTER : genMonitorEnter(frameState.apop()); break; -// case MONITOREXIT : genMonitorExit(frameState.apop(), null); break; - case MULTIANEWARRAY : genNewMultiArray(stream.readCPI()); break; - case IFNULL : genIfNull(Condition.EQ); break; - case IFNONNULL : genIfNull(Condition.NE); break; - case GOTO_W : genGoto(); break; - case JSR_W : genJsr(stream.readBranchDest()); break; - case BREAKPOINT: - throw new BailoutException("concurrent setting of breakpoint"); - default: - throw new BailoutException("Unsupported opcode " + opcode + " (" + nameOf(opcode) + ") [bci=" + bci + "]"); - } - // @formatter:on - // Checkstyle: resume - } - - private void traceInstruction(int bci, int opcode, boolean blockStart) { - if (Debug.isLogEnabled()) { - StringBuilder sb = new StringBuilder(40); - sb.append(blockStart ? '+' : '|'); - if (bci < 10) { - sb.append(" "); - } else if (bci < 100) { - sb.append(' '); - } - sb.append(bci).append(": ").append(Bytecodes.nameOf(opcode)); - for (int i = bci + 1; i < stream.nextBCI(); ++i) { - sb.append(' ').append(stream.readUByte(i)); - } - if (!currentBlock.jsrScope.isEmpty()) { - sb.append(' ').append(currentBlock.jsrScope); - } - Debug.log(sb.toString()); - } - } - - private void genArrayLength() { - throw GraalInternalError.unimplemented(); - } -} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -57,7 +57,10 @@ import com.oracle.graal.lir.amd64.AMD64ControlFlow.ReturnOp; import com.oracle.graal.lir.amd64.AMD64ControlFlow.StrategySwitchOp; import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp; +import com.oracle.graal.lir.amd64.AMD64Move.LeaOp; import com.oracle.graal.lir.amd64.AMD64Move.MembarOp; +import com.oracle.graal.lir.amd64.AMD64Move.MoveFromRegOp; +import com.oracle.graal.lir.amd64.AMD64Move.MoveToRegOp; import com.oracle.graal.lir.amd64.AMD64Move.StackLeaOp; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; @@ -76,8 +79,17 @@ private static final RegisterValue RDX_L = AMD64.rdx.asValue(Kind.Long); private static final RegisterValue RCX_I = AMD64.rcx.asValue(Kind.Int); + private class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { + + @Override + public LIRInstruction createMove(AllocatableValue result, Value input) { + return AMD64LIRGenerator.this.createMove(result, input); + } + } + public AMD64LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); + lir.setSpillMoveFactory(new AMD64SpillMoveFactory()); } @Override @@ -126,9 +138,19 @@ return result; } + protected AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { + if (src instanceof AMD64AddressValue) { + return new LeaOp(dst, (AMD64AddressValue) src); + } else if (isRegister(src) || isStackSlot(dst)) { + return new MoveFromRegOp(dst, src); + } else { + return new MoveToRegOp(dst, src); + } + } + @Override public void emitMove(AllocatableValue dst, Value src) { - append(AMD64Move.createMove(dst, src)); + append(createMove(dst, src)); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java --- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -47,6 +47,7 @@ import com.oracle.graal.lir.hsail.HSAILControlFlow.FloatCondMoveOp; import com.oracle.graal.lir.hsail.HSAILControlFlow.ReturnOp; import com.oracle.graal.lir.hsail.HSAILControlFlow.StrategySwitchOp; +import com.oracle.graal.lir.hsail.HSAILMove.LeaOp; import com.oracle.graal.lir.hsail.HSAILMove.MembarOp; import com.oracle.graal.lir.hsail.HSAILMove.MoveFromRegOp; import com.oracle.graal.lir.hsail.HSAILMove.MoveToRegOp; @@ -61,8 +62,23 @@ */ public abstract class HSAILLIRGenerator extends LIRGenerator { + public static class HSAILSpillMoveFactory implements LIR.SpillMoveFactory { + + @Override + public LIRInstruction createMove(AllocatableValue dst, Value src) { + if (src instanceof HSAILAddressValue) { + return new LeaOp(dst, (HSAILAddressValue) src); + } else if (isRegister(src) || isStackSlot(dst)) { + return new MoveFromRegOp(dst, src); + } else { + return new MoveToRegOp(dst, src); + } + } + } + public HSAILLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); + lir.setSpillMoveFactory(new HSAILSpillMoveFactory()); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -81,8 +81,17 @@ public static final ForeignCallDescriptor ARITHMETIC_FREM = new ForeignCallDescriptor("arithmeticFrem", float.class, float.class, float.class); public static final ForeignCallDescriptor ARITHMETIC_DREM = new ForeignCallDescriptor("arithmeticDrem", double.class, double.class, double.class); + public static class PTXSpillMoveFactory implements LIR.SpillMoveFactory { + + @Override + public LIRInstruction createMove(AllocatableValue result, Value input) { + throw GraalInternalError.unimplemented("PTXSpillMoveFactory.createMove()"); + } + } + public PTXLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); + lir.setSpillMoveFactory(new PTXSpillMoveFactory()); int callVariables = cc.getArgumentCount() + (cc.getReturn().equals(Value.ILLEGAL) ? 0 : 1); lir.setFirstVariableNumber(callVariables); nextPredRegNum = 0; @@ -126,7 +135,7 @@ } @Override - public void emitPrologue() { + public void emitPrologue(StructuredGraph graph) { // Need to emit .param directives based on incoming arguments and return value CallingConvention incomingArguments = cc; Object returnObject = incomingArguments.getReturn(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -52,7 +52,10 @@ import com.oracle.graal.lir.sparc.SPARCControlFlow.ReturnOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.StrategySwitchOp; import com.oracle.graal.lir.sparc.SPARCControlFlow.TableSwitchOp; +import com.oracle.graal.lir.sparc.SPARCMove.LoadAddressOp; import com.oracle.graal.lir.sparc.SPARCMove.MembarOp; +import com.oracle.graal.lir.sparc.SPARCMove.MoveFromRegOp; +import com.oracle.graal.lir.sparc.SPARCMove.MoveToRegOp; import com.oracle.graal.lir.sparc.SPARCMove.NullCheckOp; import com.oracle.graal.lir.sparc.SPARCMove.StackLoadAddressOp; import com.oracle.graal.nodes.*; @@ -67,8 +70,17 @@ */ public abstract class SPARCLIRGenerator extends LIRGenerator { + private class SPARCSpillMoveFactory implements LIR.SpillMoveFactory { + + @Override + public LIRInstruction createMove(AllocatableValue result, Value input) { + return SPARCLIRGenerator.this.createMove(result, input); + } + } + public SPARCLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); + lir.setSpillMoveFactory(new SPARCSpillMoveFactory()); } @Override @@ -104,9 +116,19 @@ return result; } + protected SPARCLIRInstruction createMove(AllocatableValue dst, Value src) { + if (src instanceof SPARCAddressValue) { + return new LoadAddressOp(dst, (SPARCAddressValue) src); + } else if (isRegister(src) || isStackSlot(dst)) { + return new MoveFromRegOp(dst, src); + } else { + return new MoveToRegOp(dst, src); + } + } + @Override public void emitMove(AllocatableValue dst, Value src) { - append(SPARCMove.createMove(dst, src)); + append(createMove(dst, src)); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CheckGraalInvariants.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.compiler.test; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import java.util.zip.*; + +import org.junit.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.internal.*; +import com.oracle.graal.java.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.phases.*; +import com.oracle.graal.phases.VerifyPhase.VerificationError; +import com.oracle.graal.phases.tiers.*; +import com.oracle.graal.phases.util.*; +import com.oracle.graal.phases.verify.*; +import com.oracle.graal.runtime.*; + +/** + * Checks that all classes in graal.jar (which must be on the class path) comply with global + * invariants such as using {@link Object#equals(Object)} to compare certain types instead of + * identity comparisons. + */ +public class CheckGraalInvariants { + + @Test + public void test() { + RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class); + Providers providers = rt.getHostBackend().getProviders(); + MetaAccessProvider metaAccess = providers.getMetaAccess(); + + PhaseSuite graphBuilderSuite = new PhaseSuite<>(); + graphBuilderSuite.appendPhase(new GraphBuilderPhase(GraphBuilderConfiguration.getEagerDefault())); + HighTierContext context = new HighTierContext(providers, new Assumptions(false), null, graphBuilderSuite, OptimisticOptimizations.NONE); + + Assume.assumeTrue(VerifyPhase.class.desiredAssertionStatus()); + + String bootclasspath = System.getProperty("sun.boot.class.path"); + Assert.assertNotNull("Cannot find value of boot class path", bootclasspath); + + bootclasspath.split(File.pathSeparator); + + String graalJar = null; + for (String e : bootclasspath.split(File.pathSeparator)) { + if (e.endsWith("graal.jar")) { + graalJar = e; + break; + } + } + Assert.assertNotNull("Could not find graal.jar on boot class path: " + bootclasspath, graalJar); + + final List classNames = new ArrayList<>(); + try { + final ZipFile zipFile = new ZipFile(new File(graalJar)); + for (final Enumeration e = zipFile.entries(); e.hasMoreElements();) { + final ZipEntry zipEntry = e.nextElement(); + String name = zipEntry.getName(); + if (name.endsWith(".class")) { + String className = name.substring(0, name.length() - ".class".length()).replace('/', '.'); + classNames.add(className); + } + } + } catch (IOException e) { + Assert.fail(e.toString()); + } + + // Allows a subset of methods to be checked through use of a system property + String property = System.getProperty(CheckGraalInvariants.class.getName() + ".filters"); + String[] filters = property == null ? null : property.split(","); + + List errors = new ArrayList<>(); + for (String className : classNames) { + try { + Class c = Class.forName(className, false, CheckGraalInvariants.class.getClassLoader()); + for (Method m : c.getDeclaredMethods()) { + if (Modifier.isNative(m.getModifiers()) || Modifier.isAbstract(m.getModifiers())) { + // ignore + } else { + String methodName = className + "." + m.getName(); + if (matches(filters, methodName)) { + StructuredGraph graph = new StructuredGraph(metaAccess.lookupJavaMethod(m)); + DebugConfig debugConfig = DebugScope.getConfig(); + DebugConfig noInterceptConfig = new DelegatingDebugConfig(debugConfig) { + @Override + public RuntimeException interceptException(Throwable e) { + return null; + } + }; + try (DebugConfigScope s = Debug.setConfig(noInterceptConfig)) { + graphBuilderSuite.apply(graph, context); + checkGraph(context, graph); + } catch (VerificationError e) { + errors.add(e.getMessage()); + } catch (LinkageError e) { + // suppress linkages errors resulting from eager resolution + } catch (BailoutException e) { + // Graal bail outs on certain patterns in Java bytecode (e.g., + // unbalanced monitors introduced by jacoco). + } catch (Throwable e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + errors.add(String.format("Error while checking %s:%n%s", methodName, sw)); + } + } + } + } + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + if (!errors.isEmpty()) { + StringBuilder msg = new StringBuilder(); + String nl = String.format("%n"); + for (String e : errors) { + if (msg.length() != 0) { + msg.append(nl); + } + msg.append(e); + } + Assert.fail(msg.toString()); + } + } + + /** + * Checks the invariants for a single graph. + */ + private static void checkGraph(HighTierContext context, StructuredGraph graph) { + new VerifyUsageWithEquals(Value.class).apply(graph, context); + new VerifyUsageWithEquals(Register.class).apply(graph, context); + new VerifyUsageWithEquals(JavaType.class).apply(graph, context); + new VerifyUsageWithEquals(JavaMethod.class).apply(graph, context); + new VerifyUsageWithEquals(JavaField.class).apply(graph, context); + } + + private static boolean matches(String[] filters, String s) { + if (filters == null || filters.length == 0) { + return true; + } + for (String filter : filters) { + if (s.contains(filter)) { + return true; + } + } + return false; + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -499,7 +499,7 @@ private CompilationResult compileBaseline(ResolvedJavaMethod javaMethod) { try (Scope bds = Debug.scope("compileBaseline")) { - BaslineCompiler baselineCompiler = new BaslineCompiler(GraphBuilderConfiguration.getDefault(), providers.getMetaAccess()); + BaselineCompiler baselineCompiler = new BaselineCompiler(GraphBuilderConfiguration.getDefault(), providers.getMetaAccess()); baselineCompiler.generate(javaMethod, -1); return null; } catch (Throwable e) { @@ -661,8 +661,8 @@ protected CompilationResult compile(ResolvedJavaMethod method, final StructuredGraph graph) { CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - return compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), - getSpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + return compileGraph(graph, null, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, + getProfilingInfo(graph), getSpeculationLog(), getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); } protected SpeculationLog getSpeculationLog() { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -62,8 +62,8 @@ final Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult cr = compileGraph(graph, null, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), + OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { @@ -85,8 +85,8 @@ assertTrue(graphLineSPs > 0); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); PhaseSuite graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerInfopointDefault()); - final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, - getProfilingInfo(graph), getSpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult cr = compileGraph(graph, null, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, + getProfilingInfo(graph), getSpeculationLog(), getSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); int lineSPs = 0; for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/AllocatorTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -42,6 +43,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.phases.*; +import com.oracle.graal.phases.schedule.*; public class AllocatorTest extends GraalCompilerTest { @@ -109,20 +111,16 @@ private RegisterStats getRegisterStats(final StructuredGraph graph) { final Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); - LIR lir = null; + SchedulePhase schedule = null; try (Scope s = Debug.scope("FrontEnd")) { - lir = GraalCompiler.emitHIR(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE, + schedule = GraalCompiler.emitHIR(getProviders(), getBackend().getTarget(), graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE, graph.method().getProfilingInfo(), new SpeculationLog(), getSuites()); } catch (Throwable e) { throw Debug.handle(e); } - try (Scope s = Debug.scope("BackEnd", lir)) { - CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), lir, graph, cc); - return new RegisterStats(lir); - } catch (Throwable e) { - throw Debug.handle(e); - } + CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); + LIRGenerator lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc); + return new RegisterStats(lirGen.lir); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Mon Mar 17 14:30:59 2014 +0100 @@ -30,9 +30,9 @@ import com.oracle.graal.alloc.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.*; +import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.meta.ProfilingInfo.*; +import com.oracle.graal.api.meta.ProfilingInfo.TriState; import com.oracle.graal.compiler.alloc.*; import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; @@ -43,7 +43,6 @@ import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; -import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.options.*; import com.oracle.graal.phases.*; @@ -131,31 +130,25 @@ * @param installedCodeOwner the method the compiled code will be * {@linkplain InstalledCode#getMethod() associated} with once installed. This * argument can be null. - * @param withScope specifies if a {@link DebugScope} with the name {@code "GraalCompiler"} - * should be used for the compilation * @return the result of the compilation */ - public static T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, - TargetDescription target, GraphCache cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, - SpeculationLog speculationLog, Suites suites, boolean withScope, T compilationResult, CompilationResultBuilderFactory factory) { + public static T compileGraph(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, + TargetDescription target, Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, + ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, T compilationResult, CompilationResultBuilderFactory factory) { assert !graph.isFrozen(); - try (Scope s0 = withScope ? Debug.scope("GraalCompiler", graph, providers.getCodeCache()) : null) { + try (Scope s0 = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) { Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); - LIR lir = null; + SchedulePhase schedule = null; try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) { - lir = emitHIR(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites); + schedule = emitHIR(providers, target, graph, assumptions, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites); } catch (Throwable e) { throw Debug.handle(e); } try (TimerCloseable a = BackEnd.start()) { LIRGenerator lirGen = null; - try (Scope s = Debug.scope("BackEnd", lir)) { - lirGen = emitLIR(backend, target, lir, graph, cc); - } catch (Throwable e) { - throw Debug.handle(e); - } + lirGen = emitLIR(backend, target, schedule, graph, stub, cc); try (Scope s = Debug.scope("CodeGen", lirGen)) { - emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner, factory); + emitCode(backend, assumptions, lirGen, compilationResult, installedCodeOwner, factory); } catch (Throwable e) { throw Debug.handle(e); } @@ -176,21 +169,11 @@ } } - private static long[] getLeafGraphIdArray(StructuredGraph graph) { - long[] leafGraphIdArray = new long[graph.getLeafGraphIds().size() + 1]; - int i = 0; - leafGraphIdArray[i++] = graph.graphId(); - for (long id : graph.getLeafGraphIds()) { - leafGraphIdArray[i++] = id; - } - return leafGraphIdArray; - } - /** * Builds the graph, optimizes it. */ - public static LIR emitHIR(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhaseSuite graphBuilderSuite, - OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) { + public static SchedulePhase emitHIR(Providers providers, TargetDescription target, StructuredGraph graph, Assumptions assumptions, Map cache, + PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites) { if (speculationLog != null) { speculationLog.collectFailedSpeculations(); @@ -215,84 +198,87 @@ suites.getLowTier().apply(graph, lowTierContext); graph.maybeCompress(); - // we do not want to store statistics about OSR compilations because it may prevent inlining - if (!graph.isOSR()) { - InliningPhase.storeStatisticsAfterLowTier(graph); - } - SchedulePhase schedule = new SchedulePhase(); schedule.apply(graph); Debug.dump(schedule, "final schedule"); + return schedule; + } + + private static void emitBlock(LIRGenerator lirGen, Block b, StructuredGraph graph, BlockMap> blockMap) { + if (lirGen.lir.lir(b) == null) { + for (Block pred : b.getPredecessors()) { + if (!b.isLoopHeader() || !pred.isLoopEnd()) { + emitBlock(lirGen, pred, graph, blockMap); + } + } + lirGen.doBlock(b, graph, blockMap); + } + } + + public static LIRGenerator emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc) { Block[] blocks = schedule.getCFG().getBlocks(); Block startBlock = schedule.getCFG().getStartBlock(); assert startBlock != null; assert startBlock.getPredecessorCount() == 0; - try (Scope s = Debug.scope("ComputeLinearScanOrder")) { - NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); - List codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock, nodeProbabilities); - List linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock, nodeProbabilities); - - LIR lir = new LIR(schedule.getCFG(), schedule.getBlockToNodesMap(), linearScanOrder, codeEmittingOrder); - Debug.dump(lir, "After linear scan order"); - return lir; - } catch (Throwable e) { - throw Debug.handle(e); - } - - } + LIR lir = null; + try (Scope ds = Debug.scope("MidEnd")) { + try (Scope s = Debug.scope("ComputeLinearScanOrder")) { + NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); + List codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock, nodeProbabilities); + List linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock, nodeProbabilities); - private static void emitBlock(LIRGenerator lirGen, Block b) { - if (lirGen.lir.lir(b) == null) { - for (Block pred : b.getPredecessors()) { - if (!b.isLoopHeader() || !pred.isLoopEnd()) { - emitBlock(lirGen, pred); - } - } - lirGen.doBlock(b); - } - } - - public static LIRGenerator emitLIR(Backend backend, TargetDescription target, LIR lir, StructuredGraph graph, CallingConvention cc) { - FrameMap frameMap = backend.newFrameMap(); - LIRGenerator lirGen = backend.newLIRGenerator(graph, frameMap, cc, lir); - - try (Scope s = Debug.scope("LIRGen", lirGen)) { - for (Block b : lir.linearScanOrder()) { - emitBlock(lirGen, b); - } - lirGen.beforeRegisterAllocation(); - - Debug.dump(lir, "After LIR generation"); - } catch (Throwable e) { - throw Debug.handle(e); - } - - try (Scope s = Debug.scope("Allocator", lirGen)) { - if (backend.shouldAllocateRegisters()) { - new LinearScan(target, lir, frameMap).allocate(); + lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder); + Debug.dump(lir, "After linear scan order"); + } catch (Throwable e) { + throw Debug.handle(e); } } catch (Throwable e) { throw Debug.handle(e); } + try (Scope ds = Debug.scope("BackEnd", lir)) { + FrameMap frameMap = backend.newFrameMap(); + LIRGenerator lirGen = backend.newLIRGenerator(graph, stub, frameMap, cc, lir); - try (Scope s = Debug.scope("ControlFlowOptimizations")) { - EdgeMoveOptimizer.optimize(lir); - ControlFlowOptimizer.optimize(lir); - if (lirGen.canEliminateRedundantMoves()) { - RedundantMoveElimination.optimize(lir, frameMap, lirGen.getGraph().method()); + try (Scope s = Debug.scope("LIRGen", lirGen)) { + for (Block b : lir.linearScanOrder()) { + emitBlock(lirGen, b, graph, schedule.getBlockToNodesMap()); + } + lirGen.beforeRegisterAllocation(); + + Debug.dump(lir, "After LIR generation"); + } catch (Throwable e) { + throw Debug.handle(e); } - NullCheckOptimizer.optimize(lir, target.implicitNullCheckLimit); + + try (Scope s = Debug.scope("Allocator", lirGen)) { + if (backend.shouldAllocateRegisters()) { + new LinearScan(target, lir, frameMap).allocate(); + } + } catch (Throwable e) { + throw Debug.handle(e); + } - Debug.dump(lir, "After control flow optimization"); + try (Scope s = Debug.scope("ControlFlowOptimizations")) { + EdgeMoveOptimizer.optimize(lir); + ControlFlowOptimizer.optimize(lir); + if (lirGen.canEliminateRedundantMoves()) { + RedundantMoveElimination.optimize(lir, frameMap); + } + NullCheckOptimizer.optimize(lir, target.implicitNullCheckLimit); + + Debug.dump(lir, "After control flow optimization"); + } catch (Throwable e) { + throw Debug.handle(e); + } + return lirGen; } catch (Throwable e) { throw Debug.handle(e); } - return lirGen; } - public static void emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, + public static void emitCode(Backend backend, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, CompilationResultBuilderFactory factory) { CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGen, compilationResult, factory); backend.emitCode(crb, lirGen.lir, installedCodeOwner); @@ -300,7 +286,6 @@ if (!assumptions.isEmpty()) { compilationResult.setAssumptions(assumptions); } - compilationResult.setLeafGraphIds(leafGraphIds); if (Debug.isMeterEnabled()) { List ldp = compilationResult.getDataReferences(); @@ -308,14 +293,9 @@ for (int i = 0; i < dms.length; i++) { dms[i] = Debug.metric("DataPatches-" + Kind.values()[i].toString()); } - DebugMetric dmRaw = Debug.metric("DataPatches-raw"); for (DataPatch dp : ldp) { - if (dp.getConstant() != null) { - dms[dp.getConstant().getKind().ordinal()].add(1); - } else { - dmRaw.add(1); - } + dms[dp.data.getKind().ordinal()].add(1); } Debug.metric("CompilationResults").increment(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Mon Mar 17 14:30:59 2014 +0100 @@ -104,7 +104,7 @@ /** * List of blocks in linear-scan order. This is only correct as long as the CFG does not change. */ - final List sortedBlocks; + final List> sortedBlocks; /** * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals. @@ -139,7 +139,7 @@ * containing the instruction. Entries should be retrieved with {@link #blockForId(int)} as the * id is not simply an index into this array. */ - Block[] opIdToBlockMap; + AbstractBlock[] opIdToBlockMap; /** * Bit set for each variable that is contained in each loop. @@ -168,16 +168,16 @@ this.registers = target.arch.getRegisters(); this.firstVariableNumber = registers.length; this.variables = new ArrayList<>(ir.numVariables() * 3 / 2); - this.blockData = new BlockMap<>(ir.cfg); + this.blockData = new BlockMap<>(ir.getControlFlowGraph()); } - public int getFirstLirInstructionId(Block block) { + public int getFirstLirInstructionId(AbstractBlock block) { int result = ir.lir(block).get(0).id(); assert result >= 0; return result; } - public int getLastLirInstructionId(Block block) { + public int getLastLirInstructionId(AbstractBlock block) { List instructions = ir.lir(block); int result = instructions.get(instructions.size() - 1).id(); assert result >= 0; @@ -321,7 +321,7 @@ return sortedBlocks.size(); } - Block blockAt(int index) { + AbstractBlock blockAt(int index) { return sortedBlocks.get(index); } @@ -335,7 +335,7 @@ } int numLoops() { - return ir.cfg.getLoops().length; + return ir.getControlFlowGraph().getLoops().length; } boolean isIntervalInLoop(int interval, int loop) { @@ -393,7 +393,7 @@ * @param opId an instruction {@linkplain LIRInstruction#id id} * @return the block containing the instruction denoted by {@code opId} */ - Block blockForId(int opId) { + AbstractBlock blockForId(int opId) { assert opIdToBlockMap.length > 0 && opId >= 0 && opId <= maxOpId() + 1 : "opId out of range"; return opIdToBlockMap[opIdToIndex(opId)]; } @@ -516,7 +516,7 @@ } LIRInsertionBuffer insertionBuffer = new LIRInsertionBuffer(); - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { List instructions = ir.lir(block); int numInst = instructions.size(); @@ -562,7 +562,7 @@ assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; - insertionBuffer.append(j + 1, frameMap.createSpillMove(toLocation, fromLocation)); + insertionBuffer.append(j + 1, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); } @@ -623,7 +623,7 @@ // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node. int numInstructions = 0; - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { numInstructions += ir.lir(block).size(); } @@ -633,7 +633,7 @@ int opId = 0; int index = 0; - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { blockData.put(block, new BlockData()); List instructions = ir.lir(block); @@ -675,7 +675,7 @@ intervalInLoop = new BitMap2D(operandSize(), numLoops()); // iterate all blocks - for (final Block block : sortedBlocks) { + for (final AbstractBlock block : sortedBlocks) { Indent indent = Debug.logAndIndent("compute local live sets for block %d", block.getId()); final BitSet liveGen = new BitSet(liveSize); @@ -779,13 +779,13 @@ } } - private void verifyInput(Block block, BitSet liveKill, Value operand) { + private void verifyInput(AbstractBlock block, BitSet liveKill, Value operand) { // fixed intervals are never live at block boundaries, so // they need not be processed in live sets. // this is checked by these assertions to be sure about it. // the entry block may have incoming // values in registers, which is ok. - if (isRegister(operand) && block != ir.cfg.getStartBlock()) { + if (isRegister(operand) && block != ir.getControlFlowGraph().getStartBlock()) { if (isProcessed(operand)) { assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block"; } @@ -813,7 +813,7 @@ // iterate all blocks in reverse order for (int i = numBlocks - 1; i >= 0; i--) { - Block block = blockAt(i); + AbstractBlock block = blockAt(i); BlockData blockSets = blockData.get(block); changeOccurredInBlock = false; @@ -824,7 +824,7 @@ // block has successors if (n > 0) { liveOut.clear(); - for (Block successor : block.getSuccessors()) { + for (AbstractBlock successor : block.getSuccessors()) { liveOut.or(blockData.get(successor).liveIn); } } else { @@ -869,7 +869,7 @@ } // check that the liveIn set of the first block is empty - Block startBlock = ir.cfg.getStartBlock(); + Block startBlock = ir.getControlFlowGraph().getStartBlock(); if (blockData.get(startBlock).liveIn.cardinality() != 0) { if (DetailedAsserts.getValue()) { reportFailure(numBlocks); @@ -897,99 +897,85 @@ return null; } - private static StructuredGraph getGraphFromDebugContext() { - LIRGenerator gen = getLIRGeneratorFromDebugContext(); - if (gen != null) { - return gen.getGraph(); - } - return null; - } + private void reportFailure(int numBlocks) { + try (Scope s = Debug.forceLog()) { + Indent indent = Debug.logAndIndent("report failure"); - private static ResolvedJavaMethod getMethodFromDebugContext() { - StructuredGraph graph = getGraphFromDebugContext(); - if (graph != null) { - return graph.method(); - } - return null; - } + BitSet startBlockLiveIn = blockData.get(ir.getControlFlowGraph().getStartBlock()).liveIn; + try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { + for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { + Value operand = operandFor(operandNum); + Debug.log("var %d; operand=%s; node=%s", operandNum, operand, getValueForOperandFromDebugContext(operand)); + } + } - private void reportFailure(int numBlocks) { - Indent indent = Debug.logAndIndent("report failure, graph: %s", getGraphFromDebugContext()); - - BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn; - try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { + // print some additional information to simplify debugging for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { Value operand = operandFor(operandNum); - Debug.log("var %d; operand=%s; node=%s", operandNum, operand, getValueForOperandFromDebugContext(operand)); - } - } + final Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, getValueForOperandFromDebugContext(operand)); - // print some additional information to simplify debugging - for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { - Value operand = operandFor(operandNum); - final Indent indent2 = Debug.logAndIndent("---- Detailed information for var %d; operand=%s; node=%s ----", operandNum, operand, getValueForOperandFromDebugContext(operand)); + Deque> definedIn = new ArrayDeque<>(); + HashSet> usedIn = new HashSet<>(); + for (AbstractBlock block : sortedBlocks) { + if (blockData.get(block).liveGen.get(operandNum)) { + usedIn.add(block); + try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { + for (LIRInstruction ins : ir.lir(block)) { + try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) { + ins.forEachState(new ValueProcedure() { - Deque definedIn = new ArrayDeque<>(); - HashSet usedIn = new HashSet<>(); - for (Block block : sortedBlocks) { - if (blockData.get(block).liveGen.get(operandNum)) { - usedIn.add(block); - try (Indent indent3 = Debug.logAndIndent("used in block B%d", block.getId())) { - for (LIRInstruction ins : ir.lir(block)) { - try (Indent indent4 = Debug.logAndIndent("%d: %s", ins.id(), ins)) { - ins.forEachState(new ValueProcedure() { - - @Override - public Value doValue(Value liveStateOperand) { - Debug.log("operand=%s", liveStateOperand); - return liveStateOperand; - } - }); + @Override + public Value doValue(Value liveStateOperand) { + Debug.log("operand=%s", liveStateOperand); + return liveStateOperand; + } + }); + } + } + } + } + if (blockData.get(block).liveKill.get(operandNum)) { + definedIn.add(block); + try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) { + for (LIRInstruction ins : ir.lir(block)) { + Debug.log("%d: %s", ins.id(), ins); } } } } - if (blockData.get(block).liveKill.get(operandNum)) { - definedIn.add(block); - try (Indent indent3 = Debug.logAndIndent("defined in block B%d", block.getId())) { - for (LIRInstruction ins : ir.lir(block)) { - Debug.log("%d: %s", ins.id(), ins); + + int[] hitCount = new int[numBlocks]; + + while (!definedIn.isEmpty()) { + AbstractBlock block = definedIn.removeFirst(); + usedIn.remove(block); + for (AbstractBlock successor : block.getSuccessors()) { + if (successor.isLoopHeader()) { + if (!block.isLoopEnd()) { + definedIn.add(successor); + } + } else { + if (++hitCount[successor.getId()] == successor.getPredecessorCount()) { + definedIn.add(successor); + } } } } - } - - int[] hitCount = new int[numBlocks]; - - while (!definedIn.isEmpty()) { - Block block = definedIn.removeFirst(); - usedIn.remove(block); - for (Block successor : block.getSuccessors()) { - if (successor.isLoopHeader()) { - if (!block.isLoopEnd()) { - definedIn.add(successor); - } - } else { - if (++hitCount[successor.getId()] == successor.getPredecessorCount()) { - definedIn.add(successor); - } + try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { + for (AbstractBlock block : usedIn) { + Debug.log("B%d", block.getId()); } } + indent2.outdent(); } - try (Indent indent3 = Debug.logAndIndent("**** offending usages are in: ")) { - for (Block block : usedIn) { - Debug.log("B%d", block.getId()); - } - } - indent2.outdent(); + indent.outdent(); } - indent.outdent(); } private void verifyLiveness() { // check that fixed intervals are not live at block boundaries // (live set must be empty at fixed intervals) - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { for (int j = 0; j <= maxRegisterNumber(); j++) { assert !blockData.get(block).liveIn.get(j) : "liveIn set of fixed register must be empty"; assert !blockData.get(block).liveOut.get(j) : "liveOut set of fixed register must be empty"; @@ -1172,7 +1158,7 @@ // iterate all blocks in reverse order for (int i = blockCount() - 1; i >= 0; i--) { - Block block = blockAt(i); + AbstractBlock block = blockAt(i); Indent indent2 = Debug.logAndIndent("handle block %d", block.getId()); List instructions = ir.lir(block); @@ -1477,14 +1463,14 @@ throw new BailoutException("LinearScan: interval is null"); } - Interval intervalAtBlockBegin(Block block, Value operand) { + Interval intervalAtBlockBegin(AbstractBlock block, Value operand) { assert isVariable(operand) : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; return splitChildAtOpId(intervalFor(operand), getFirstLirInstructionId(block), LIRInstruction.OperandMode.DEF); } - Interval intervalAtBlockEnd(Block block, Value operand) { + Interval intervalAtBlockEnd(AbstractBlock block, Value operand) { assert isVariable(operand) : "register number out of bounds"; assert intervalFor(operand) != null : "no interval found"; @@ -1498,7 +1484,7 @@ return splitChildAtOpId(intervalFor(operand), opId, LIRInstruction.OperandMode.USE); } - void resolveCollectMappings(Block fromBlock, Block toBlock, MoveResolver moveResolver) { + void resolveCollectMappings(AbstractBlock fromBlock, AbstractBlock toBlock, MoveResolver moveResolver) { assert moveResolver.checkEmpty(); int numOperands = operandSize(); @@ -1520,7 +1506,7 @@ } } - void resolveFindInsertPos(Block fromBlock, Block toBlock, MoveResolver moveResolver) { + void resolveFindInsertPos(AbstractBlock fromBlock, AbstractBlock toBlock, MoveResolver moveResolver) { if (fromBlock.getSuccessorCount() <= 1) { Debug.log("inserting moves at end of fromBlock B%d", fromBlock.getId()); @@ -1543,7 +1529,7 @@ // successor edges, blocks which are reached by switch statements // may have be more than one predecessor but it will be guaranteed // that all predecessors will be the same. - for (Block predecessor : toBlock.getPredecessors()) { + for (AbstractBlock predecessor : toBlock.getPredecessors()) { assert fromBlock == predecessor : "all critical edges must be broken"; } } @@ -1564,7 +1550,7 @@ BitSet blockCompleted = new BitSet(numBlocks); BitSet alreadyResolved = new BitSet(numBlocks); - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { // check if block has only one predecessor and only one successor if (block.getPredecessorCount() == 1 && block.getSuccessorCount() == 1) { @@ -1574,8 +1560,8 @@ // check if block is empty (only label and branch) if (instructions.size() == 2) { - Block pred = block.getFirstPredecessor(); - Block sux = block.getFirstSuccessor(); + AbstractBlock pred = block.getPredecessors().iterator().next(); + AbstractBlock sux = block.getSuccessors().iterator().next(); // prevent optimization of two consecutive blocks if (!blockCompleted.get(pred.getLinearScanNumber()) && !blockCompleted.get(sux.getLinearScanNumber())) { @@ -1595,12 +1581,12 @@ } } - for (Block fromBlock : sortedBlocks) { + for (AbstractBlock fromBlock : sortedBlocks) { if (!blockCompleted.get(fromBlock.getLinearScanNumber())) { alreadyResolved.clear(); alreadyResolved.or(blockCompleted); - for (Block toBlock : fromBlock.getSuccessors()) { + for (AbstractBlock toBlock : fromBlock.getSuccessors()) { // check for duplicate edges between the same blocks (can happen with switch // blocks) @@ -1644,7 +1630,7 @@ if (opId != -1) { if (DetailedAsserts.getValue()) { - Block block = blockForId(opId); + AbstractBlock block = blockForId(opId); if (block.getSuccessorCount() <= 1 && opId == getLastLirInstructionId(block)) { // check if spill moves could have been appended at the end of this block, but // before the branch instruction. So the split child information for this branch @@ -1758,7 +1744,7 @@ public Value doValue(Value operand) { int tempOpId = op.id(); OperandMode mode = OperandMode.USE; - Block block = blockForId(tempOpId); + AbstractBlock block = blockForId(tempOpId); if (block.getSuccessorCount() == 1 && tempOpId == getLastLirInstructionId(block)) { // generating debug information for the last instruction of a block. // if this instruction is a branch, spill moves are inserted before this branch @@ -1769,7 +1755,7 @@ final LIRInstruction instr = ir.lir(block).get(ir.lir(block).size() - 1); if (instr instanceof StandardOp.JumpOp) { if (blockData.get(block).liveOut.get(operandNumber(operand))) { - tempOpId = getFirstLirInstructionId(block.getFirstSuccessor()); + tempOpId = getFirstLirInstructionId(block.getSuccessors().iterator().next()); mode = OperandMode.DEF; } } @@ -1858,7 +1844,7 @@ private void assignLocations() { IntervalWalker iw = initIntervalWalker(IS_STACK_INTERVAL); try (Indent indent = Debug.logAndIndent("assign locations")) { - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { try (Indent indent2 = Debug.logAndIndent("assign locations in block B%d", block.getId())) { assignLocations(ir.lir(block), iw); } @@ -1871,7 +1857,7 @@ /* * This is the point to enable debug logging for the whole register allocation. */ - Indent indent = Debug.logAndIndent("LinearScan allocate %s", getMethodFromDebugContext()); + Indent indent = Debug.logAndIndent("LinearScan allocate"); try (Scope s = Debug.scope("LifetimeAnalysis")) { numberInstructions(); @@ -1935,7 +1921,7 @@ try (Indent indent2 = Debug.logAndIndent("Basic Blocks")) { for (int i = 0; i < blockCount(); i++) { - Block block = blockAt(i); + AbstractBlock block = blockAt(i); Debug.log("B%d [%d, %d, %s] ", block.getId(), getFirstLirInstructionId(block), getLastLirInstructionId(block), block.getLoop()); } } @@ -2073,7 +2059,7 @@ otherIntervals.addRange(Integer.MAX_VALUE - 2, Integer.MAX_VALUE - 1); IntervalWalker iw = new IntervalWalker(this, fixedIntervals, otherIntervals); - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { List instructions = ir.lir(block); for (int j = 0; j < instructions.size(); j++) { @@ -2111,7 +2097,7 @@ void verifyConstants() { try (Indent indent = Debug.logAndIndent("verifying that unpinned constants are not alive across block boundaries")) { - for (Block block : sortedBlocks) { + for (AbstractBlock block : sortedBlocks) { BitSet liveAtEdge = blockData.get(block).liveIn; // visit all operands where the liveAtEdge bit is set diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScanWalker.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScanWalker.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScanWalker.java Mon Mar 17 14:30:59 2014 +0100 @@ -25,6 +25,7 @@ import static com.oracle.graal.api.code.CodeUtil.*; import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRValueUtil.*; + import java.util.*; import com.oracle.graal.api.code.*; @@ -57,11 +58,11 @@ return allocator.blockCount(); } - Block blockAt(int idx) { + AbstractBlock blockAt(int idx) { return allocator.blockAt(idx); } - Block blockOfOpWithId(int opId) { + AbstractBlock blockOfOpWithId(int opId) { return allocator.blockForId(opId); } @@ -235,7 +236,7 @@ // optimized away later in assignRegNums int opId = (operandId + 1) & ~1; - Block opBlock = allocator.blockForId(opId); + AbstractBlock opBlock = allocator.blockForId(opId); assert opId > 0 && allocator.blockForId(opId - 2) == opBlock : "cannot insert move at block boundary"; // calculate index of instruction inside instruction list of current block @@ -259,7 +260,7 @@ moveResolver.addMapping(srcIt, dstIt); } - int findOptimalSplitPos(Block minBlock, Block maxBlock, int maxSplitPos) { + int findOptimalSplitPos(AbstractBlock minBlock, AbstractBlock maxBlock, int maxSplitPos) { int fromBlockNr = minBlock.getLinearScanNumber(); int toBlockNr = maxBlock.getLinearScanNumber(); @@ -276,7 +277,7 @@ int minLoopDepth = maxBlock.getLoopDepth(); for (int i = toBlockNr - 1; i >= fromBlockNr; i--) { - Block cur = blockAt(i); + AbstractBlock cur = blockAt(i); if (cur.getLoopDepth() < minLoopDepth) { // block with lower loop-depth found . split at the end of this block @@ -304,13 +305,13 @@ // beginning of a block, then minSplitPos is also a possible split position. // Use the block before as minBlock, because then minBlock.lastLirInstructionId() + 2 == // minSplitPos - Block minBlock = allocator.blockForId(minSplitPos - 1); + AbstractBlock minBlock = allocator.blockForId(minSplitPos - 1); // reason for using maxSplitPos - 1: otherwise there would be an assert on failure // when an interval ends at the end of the last block of the method // (in this case, maxSplitPos == allocator().maxLirOpId() + 2, and there is no // block at this opId) - Block maxBlock = allocator.blockForId(maxSplitPos - 1); + AbstractBlock maxBlock = allocator.blockForId(maxSplitPos - 1); assert minBlock.getLinearScanNumber() <= maxBlock.getLinearScanNumber() : "invalid order"; if (minBlock == maxBlock) { @@ -348,7 +349,7 @@ // Desired result: uses tagged as shouldHaveRegister inside a loop cause // a reloading // of the interval (normally, only mustHaveRegister causes a reloading) - Block loopBlock = allocator.blockForId(loopEndPos); + AbstractBlock loopBlock = allocator.blockForId(loopEndPos); Debug.log("interval is used in loop that ends in block B%d, so trying to move maxBlock back from B%d to B%d", loopBlock.getId(), maxBlock.getId(), loopBlock.getId()); assert loopBlock != minBlock : "loopBlock and minBlock must be different because block boundary is needed between"; @@ -412,8 +413,8 @@ Debug.log("splitting at position %d", optimalSplitPos); - assert allocator.isBlockBegin(optimalSplitPos) || (optimalSplitPos % 2 == 1) : "split pos must be odd when not on block boundary"; - assert !allocator.isBlockBegin(optimalSplitPos) || (optimalSplitPos % 2 == 0) : "split pos must be even on block boundary"; + assert allocator.isBlockBegin(optimalSplitPos) || ((optimalSplitPos & 1) == 1) : "split pos must be odd when not on block boundary"; + assert !allocator.isBlockBegin(optimalSplitPos) || ((optimalSplitPos & 1) == 0) : "split pos must be even on block boundary"; Interval splitPart = interval.split(optimalSplitPos, allocator); @@ -492,8 +493,8 @@ } try (Indent indent2 = Debug.logAndIndent("splitting at position %d", optimalSplitPos)) { - assert allocator.isBlockBegin(optimalSplitPos) || (optimalSplitPos % 2 == 1) : "split pos must be odd when not on block boundary"; - assert !allocator.isBlockBegin(optimalSplitPos) || (optimalSplitPos % 2 == 0) : "split pos must be even on block boundary"; + assert allocator.isBlockBegin(optimalSplitPos) || ((optimalSplitPos & 1) == 1) : "split pos must be odd when not on block boundary"; + assert !allocator.isBlockBegin(optimalSplitPos) || ((optimalSplitPos & 1) == 0) : "split pos must be even on block boundary"; Interval spilledPart = interval.split(optimalSplitPos, allocator); allocator.assignSpillSlot(spilledPart); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Mon Mar 17 14:30:59 2014 +0100 @@ -202,7 +202,7 @@ AllocatableValue fromOpr = fromInterval.operand; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.frameMap.createSpillMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx); } @@ -212,7 +212,7 @@ assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.frameMap.createSpillMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/RegisterVerifier.java Mon Mar 17 14:30:59 2014 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.compiler.alloc; import static com.oracle.graal.api.code.ValueUtil.*; + import java.util.*; import com.oracle.graal.api.code.*; @@ -39,7 +40,7 @@ final class RegisterVerifier { LinearScan allocator; - List workList; // all blocks that must be processed + List> workList; // all blocks that must be processed ArrayMap savedStates; // saved information of previous check // simplified access to methods of LinearScan @@ -53,15 +54,15 @@ } // accessors - Interval[] stateForBlock(Block block) { + Interval[] stateForBlock(AbstractBlock block) { return savedStates.get(block.getId()); } - void setStateForBlock(Block block, Interval[] savedState) { + void setStateForBlock(AbstractBlock block, Interval[] savedState) { savedStates.put(block.getId(), savedState); } - void addToWorkList(Block block) { + void addToWorkList(AbstractBlock block) { if (!workList.contains(block)) { workList.add(block); } @@ -74,7 +75,7 @@ } - void verify(Block start) { + void verify(AbstractBlock start) { // setup input registers (method arguments) for first block Interval[] inputState = new Interval[stateSize()]; setStateForBlock(start, inputState); @@ -82,14 +83,14 @@ // main loop for verification do { - Block block = workList.get(0); + AbstractBlock block = workList.get(0); workList.remove(0); processBlock(block); } while (!workList.isEmpty()); } - private void processBlock(Block block) { + private void processBlock(AbstractBlock block) { try (Indent indent = Debug.logAndIndent("processBlock B%d", block.getId())) { // must copy state because it is modified Interval[] inputState = copy(stateForBlock(block)); @@ -108,13 +109,13 @@ processOperations(allocator.ir.lir(block), inputState); // iterate all successors - for (Block succ : block.getSuccessors()) { + for (AbstractBlock succ : block.getSuccessors()) { processSuccessor(succ, inputState); } } } - private void processSuccessor(Block block, Interval[] inputState) { + private void processSuccessor(AbstractBlock block, Interval[] inputState) { Interval[] savedState = stateForBlock(block); if (savedState != null) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java Mon Mar 17 14:30:59 2014 +0100 @@ -45,8 +45,8 @@ this.nodeOperands = nodeOperands; } - protected HashMap virtualObjects = new HashMap<>(); - protected IdentityHashMap objectStates = new IdentityHashMap<>(); + protected final HashMap virtualObjects = new HashMap<>(); + protected final IdentityHashMap objectStates = new IdentityHashMap<>(); public LIRFrameState build(FrameState topState, LabelRef exceptionEdge) { assert virtualObjects.size() == 0; @@ -56,9 +56,6 @@ FrameState current = topState; do { for (EscapeObjectState state : current.virtualObjectMappings()) { - if (objectStates == null) { - objectStates = new IdentityHashMap<>(); - } if (!objectStates.containsKey(state.object())) { if (!(state instanceof MaterializedObjectState) || ((MaterializedObjectState) state).materializedValue() != state.object()) { objectStates.put(state.object(), state); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -72,7 +72,6 @@ public final NodeMap nodeOperands; public final LIR lir; - protected final StructuredGraph graph; private final Providers providers; protected final CallingConvention cc; @@ -172,7 +171,6 @@ public abstract boolean canStoreConstant(Constant c, boolean isCompressed); public LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { - this.graph = graph; this.providers = providers; this.frameMap = frameMap; this.cc = cc; @@ -220,10 +218,6 @@ return providers.getForeignCalls(); } - public StructuredGraph getGraph() { - return graph; - } - /** * Determines whether the code being generated makes at least one foreign call. */ @@ -347,7 +341,7 @@ } public LabelRef getLIRBlock(FixedNode b) { - Block result = lir.cfg.blockFor(b); + Block result = lir.getControlFlowGraph().blockFor(b); int suxIndex = currentBlock.getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; @@ -415,7 +409,7 @@ lir.lir(currentBlock).add(op); } - public void doBlock(Block block) { + public void doBlock(Block block, StructuredGraph graph, BlockMap> blockMap) { if (printIRWithLIR) { TTY.print(block.toString()); } @@ -432,14 +426,14 @@ TTY.println("BEGIN Generating LIR for block B" + block.getId()); } - if (block == lir.cfg.getStartBlock()) { + if (block == lir.getControlFlowGraph().getStartBlock()) { assert block.getPredecessorCount() == 0; - emitPrologue(); + emitPrologue(graph); } else { assert block.getPredecessorCount() > 0; } - List nodes = lir.nodesFor(block); + List nodes = blockMap.get(block); for (int i = 0; i < nodes.size(); i++) { Node instr = nodes.get(i); if (traceLevel >= 3) { @@ -528,7 +522,7 @@ } } - protected void emitPrologue() { + protected void emitPrologue(StructuredGraph graph) { CallingConvention incomingArguments = cc; Value[] params = new Value[incomingArguments.getArgumentCount()]; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Mon Mar 17 14:30:59 2014 +0100 @@ -25,15 +25,12 @@ import static com.oracle.graal.compiler.phases.HighTier.Options.*; import static com.oracle.graal.phases.GraalOptions.*; -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; import com.oracle.graal.loop.phases.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.options.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.tiers.*; -import com.oracle.graal.phases.verify.*; import com.oracle.graal.virtual.phases.ea.*; public class HighTier extends PhaseSuite { @@ -41,8 +38,6 @@ public static class Options { // @formatter:off - @Option(help = "") - public static final OptionValue VerifyUsageWithEquals = new OptionValue<>(true); @Option(help = "Enable inlining") public static final OptionValue Inline = new OptionValue<>(true); // @formatter:on @@ -51,11 +46,6 @@ public HighTier() { CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!ImmutableCode.getValue()); - if (VerifyUsageWithEquals.getValue()) { - appendPhase(new VerifyUsageWithEquals(Value.class)); - appendPhase(new VerifyUsageWithEquals(Register.class)); - } - if (OptCanonicalizer.getValue()) { appendPhase(canonicalizer); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Mon Mar 17 14:30:59 2014 +0100 @@ -65,7 +65,7 @@ public abstract FrameMap newFrameMap(); - public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir); + public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir); /** * Creates the assembler used to emit the machine code. diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Mon Mar 17 14:30:59 2014 +0100 @@ -204,6 +204,20 @@ } } + public static Scope forceLog() { + return Debug.sandbox("forceLog", new DelegatingDebugConfig(DebugScope.getConfig()) { + @Override + public boolean isLogEnabled() { + return true; + } + + @Override + public boolean isLogEnabledForMethod() { + return true; + } + }); + } + /** * Handles an exception in the context of the debug scope just exited. The just exited scope * must have the current scope as its parent which will be the case if the try-with-resource diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugHistogramAsciiPrinter.java Mon Mar 17 14:30:59 2014 +0100 @@ -62,7 +62,7 @@ public void print(DebugHistogram histogram) { List list = histogram.getValues(); if (list.isEmpty()) { - os.printf("%s is empty.\n", histogram.getName()); + os.printf("%s is empty.%n", histogram.getName()); return; } @@ -73,7 +73,7 @@ } // Print header. - os.printf("%s has %d unique elements and %d total elements:\n", histogram.getName(), list.size(), total); + os.printf("%s has %d unique elements and %d total elements:%n", histogram.getName(), list.size(), total); int max = list.get(0).getCount(); final int lineSize = nameSize + NumberSize + barSize + 10; @@ -96,6 +96,6 @@ private static void printLine(PrintStream printStream, char c, int lineSize) { char[] charArr = new char[lineSize]; Arrays.fill(charArr, c); - printStream.printf("%s\n", new String(charArr)); + printStream.printf("%s%n", new String(charArr)); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java Mon Mar 17 14:30:59 2014 +0100 @@ -228,17 +228,16 @@ * @param name the name of the new scope * @param sandboxConfig the configuration to use for a new top level scope, or null if the new * scope should be a child scope - * @param context objects to be appended to the debug context + * @param newContextObjects objects to be appended to the debug context * @return the new scope which will be exited when its {@link #close()} method is called */ - @SuppressWarnings("hiding") - public DebugScope scope(String name, DebugConfig sandboxConfig, Object... context) { + public DebugScope scope(String name, DebugConfig sandboxConfig, Object... newContextObjects) { DebugScope newScope = null; if (sandboxConfig != null) { - newScope = new DebugScope(name, name, this, true, context); + newScope = new DebugScope(name, name, this, true, newContextObjects); configTL.set(sandboxConfig); } else { - newScope = this.createChild(name, context); + newScope = this.createChild(name, newContextObjects); } instanceTL.set(newScope); newScope.updateFlags(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Mon Mar 17 14:30:59 2014 +0100 @@ -535,18 +535,22 @@ } private void maybeNotifyChanged(Node usage) { - assert graph == null || !graph.isFrozen(); - NodeChangedListener listener = graph.inputChangedListener; - if (listener != null) { - listener.nodeChanged(usage); + if (graph != null) { + assert !graph.isFrozen(); + NodeChangedListener listener = graph.inputChangedListener; + if (listener != null) { + listener.nodeChanged(usage); + } } } private void maybeNotifyZeroInputs(Node oldInput) { - assert graph == null || !graph.isFrozen(); - NodeChangedListener listener = graph.usagesDroppedToZeroListener; - if (listener != null) { - listener.nodeChanged(oldInput); + if (graph != null) { + assert !graph.isFrozen(); + NodeChangedListener listener = graph.usagesDroppedToZeroListener; + if (listener != null) { + listener.nodeChanged(oldInput); + } } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Mon Mar 17 14:30:59 2014 +0100 @@ -970,8 +970,8 @@ int index = startIndex; while (index < inputOffsets.length) { NodeList list = getNodeList(node, inputOffsets[index]); + assert list != null : clazz; putNodeList(node, inputOffsets[index], updateInputListCopy(list, node, duplicationReplacement)); - assert list != null : clazz; index++; } } @@ -980,8 +980,8 @@ int index = startIndex; while (index < successorOffsets.length) { NodeList list = getNodeList(node, successorOffsets[index]); + assert list != null : clazz; putNodeList(node, successorOffsets[index], updateSuccListCopy(list, node, duplicationReplacement)); - assert list != null : clazz; index++; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeList.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeList.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeList.java Mon Mar 17 14:30:59 2014 +0100 @@ -257,7 +257,7 @@ } @Override - public void snapshotTo(List to) { + public void snapshotTo(Collection to) { for (int i = 0; i < size; i++) { to.add(get(i)); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/AbstractNodeIterable.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/AbstractNodeIterable.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/AbstractNodeIterable.java Mon Mar 17 14:30:59 2014 +0100 @@ -74,7 +74,7 @@ } @Override - public void snapshotTo(List to) { + public void snapshotTo(Collection to) { for (T n : this) { to.add(n); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/iterators/NodeIterable.java Mon Mar 17 14:30:59 2014 +0100 @@ -44,7 +44,7 @@ List snapshot(); - void snapshotTo(List to); + void snapshotTo(Collection to); T first(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -72,8 +72,8 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { - return new AMD64HotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { + return new AMD64HotSpotLIRGenerator(graph, stub, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } /** diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Mon Mar 17 14:30:59 2014 +0100 @@ -89,7 +89,7 @@ final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; - return new TargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -71,10 +71,13 @@ private final HotSpotVMConfig config; - protected AMD64HotSpotLIRGenerator(StructuredGraph graph, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { + private final Object stub; + + protected AMD64HotSpotLIRGenerator(StructuredGraph graph, Object stub, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); assert config.basicLockSize == 8; this.config = config; + this.stub = stub; } @Override @@ -154,7 +157,7 @@ } @Override - protected void emitPrologue() { + protected void emitPrologue(StructuredGraph graph) { CallingConvention incomingArguments = cc; @@ -205,7 +208,7 @@ @Override protected boolean needOnlyOopMaps() { // Stubs only need oop maps - return graph.start() instanceof StubStartNode; + return stub != null; } /** @@ -233,22 +236,18 @@ } Stub getStub() { - if (graph.start() instanceof StubStartNode) { - return ((StubStartNode) graph.start()).getStub(); - } - return null; + return (Stub) stub; } @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { - Stub stub = getStub(); boolean destroysRegisters = linkage.destroysRegisters(); AMD64SaveRegistersOp save = null; StackSlot[] savedRegisterLocations = null; if (destroysRegisters) { - if (stub != null) { - if (stub.preservesRegisters()) { + if (getStub() != null) { + if (getStub().preservesRegisters()) { Register[] savedRegisters = frameMap.registerConfig.getAllocatableRegisters(); savedRegisterLocations = new StackSlot[savedRegisters.length]; for (int i = 0; i < savedRegisters.length; i++) { @@ -275,8 +274,8 @@ } if (destroysRegisters) { - if (stub != null) { - if (stub.preservesRegisters()) { + if (getStub() != null) { + if (getStub().preservesRegisters()) { assert !calleeSaveInfo.containsKey(currentRuntimeCallInfo); calleeSaveInfo.put(currentRuntimeCallInfo, save); @@ -474,8 +473,6 @@ protected static Constant compress(Constant c, CompressEncoding encoding) { if (c.getKind() == Kind.Long) { return Constant.forIntegerKind(Kind.Int, (int) (((c.asLong() - encoding.base) >> encoding.shift) & 0xffffffffL), c.getPrimitiveAnnotation()); - } else if (c.getKind() == Kind.Object) { - return Constant.forNarrowOop(c.asObject()); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -524,8 +521,7 @@ if (canStoreConstant(c, isCompressed)) { if (isCompressed) { if (c.getKind() == Kind.Object) { - Constant value = c.isNull() ? c : compress(c, config.getOopEncoding()); - append(new StoreCompressedConstantOp(kind, storeAddress, value, state)); + append(new StoreCompressedConstantOp(kind, storeAddress, c, state)); } else if (c.getKind() == Kind.Long) { // It's always a good idea to directly store compressed constants since they // have to be materialized as 64 bits encoded otherwise. diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Mon Mar 17 14:30:59 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; +import com.oracle.graal.hotspot.data.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.amd64.*; import com.oracle.graal.lir.amd64.AMD64Move.LoadOp; @@ -51,6 +52,9 @@ public void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (kind == Kind.Long) { if (NumUtil.isInt(input.asLong())) { + if (input.getPrimitiveAnnotation() != null) { + crb.recordInlineDataInCode(new MetaspaceData(0, input.asLong(), input.getPrimitiveAnnotation(), true)); + } masm.movl(address.toAddress(), (int) input.asLong()); } else { throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory"); @@ -59,7 +63,7 @@ if (input.isNull()) { masm.movl(address.toAddress(), 0); } else if (crb.target.inlineObjects) { - crb.recordInlineDataInCode(input); + crb.recordInlineDataInCode(new OopData(0, input.asObject(), true)); masm.movl(address.toAddress(), 0xDEADDEAD); } else { throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to memory"); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Mon Mar 17 14:30:59 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.nodes.type.*; public class AMD64HotSpotRegisterConfig implements RegisterConfig { @@ -61,9 +62,16 @@ return categorized.get(kind); } + PlatformKind primitiveKind; + if (kind == NarrowOopStamp.NarrowOop) { + primitiveKind = Kind.Int; + } else { + primitiveKind = kind; + } + ArrayList list = new ArrayList<>(); for (Register reg : getAllocatableRegisters()) { - if (architecture.canStoreValue(reg.getRegisterCategory(), kind)) { + if (architecture.canStoreValue(reg.getRegisterCategory(), primitiveKind)) { list.add(reg); } } @@ -211,7 +219,7 @@ if (locations[i] == null) { locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/ForEachToGraal.java Mon Mar 17 14:30:59 2014 +0100 @@ -82,13 +82,13 @@ NodeIterable calls = graph.getNodes(MethodCallTargetNode.class); assert calls.count() == 1; ResolvedJavaMethod lambdaMethod = calls.first().targetMethod(); - assert lambdaMethod.getName().startsWith("lambda$"); Debug.log("target ... " + lambdaMethod); if (lambdaMethod == null) { Debug.log("Did not find call in accept()"); return null; } + assert lambdaMethod.getName().startsWith("lambda$"); ExternalCompilationResult hsailCode = backend.compileKernel(lambdaMethod, true); return backend.installKernel(lambdaMethod, hsailCode); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -132,8 +132,8 @@ graphBuilderSuite.appendPhase(new NonNullParametersPhase()); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Suites suites = providers.getSuites().getDefaultSuites(); - ExternalCompilationResult hsailCode = compileGraph(graph, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), null, - suites, true, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); + ExternalCompilationResult hsailCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), + null, suites, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); if (makeBinary) { if (!deviceInitialized) { @@ -188,7 +188,7 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { return new HSAILHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackendFactory.java Mon Mar 17 14:30:59 2014 +0100 @@ -62,7 +62,7 @@ final int stackFrameAlignment = 8; final int implicitNullCheckLimit = 0; final boolean inlineObjects = true; - return new TargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + return new HotSpotTargetDescription(new HSAIL(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); } public String getArchitecture() { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -162,7 +162,7 @@ if (canStoreConstant(c, isCompressed)) { if (isCompressed) { if ((c.getKind() == Kind.Object) && c.isNull()) { - append(new StoreConstantOp(Kind.NarrowOop, storeAddress, c, state)); + append(new StoreConstantOp(Kind.Int, storeAddress, Constant.forInt(0), state)); } else { throw GraalInternalError.shouldNotReachHere("can't handle: " + access); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -41,7 +41,6 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.GraphProducer; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.lir.*; import com.oracle.graal.lir.LIRInstruction.OperandFlag; @@ -165,30 +164,6 @@ return deviceInitialized; } - @Override - public GraphProducer getGraphProducer() { - if (!deviceInitialized) { - // GPU could not be initialized so offload is disabled - return null; - } - return new GraphProducer() { - - public StructuredGraph getGraphFor(ResolvedJavaMethod method) { - if (canOffloadToGPU(method)) { - ExternalCompilationResult ptxCode = PTXHotSpotBackend.this.compileKernel(method, true); - HotSpotNmethod installedPTXCode = PTXHotSpotBackend.this.installKernel(method, ptxCode); - return new PTXWrapperBuilder(method, installedPTXCode, getRuntime().getHostBackend().getProviders()).getGraph(); - } - return null; - } - - private boolean canOffloadToGPU(ResolvedJavaMethod method) { - HotSpotVMConfig config = getRuntime().getConfig(); - return config.gpuOffload && method.getName().contains("lambda$") & method.isSynthetic(); - } - }; - } - /** * Compiles a given method to PTX code. * @@ -204,8 +179,8 @@ PhaseSuite graphBuilderSuite = providers.getSuites().getDefaultGraphBuilderSuite(); graphBuilderSuite.appendPhase(new NonNullParametersPhase()); Suites suites = providers.getSuites().getDefaultSuites(); - ExternalCompilationResult ptxCode = compileGraph(graph, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), null, - suites, true, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); + ExternalCompilationResult ptxCode = compileGraph(graph, null, cc, method, providers, this, this.getTarget(), null, graphBuilderSuite, OptimisticOptimizations.NONE, getProfilingInfo(graph), + null, suites, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); if (makeBinary) { try (Scope ds = Debug.scope("GeneratingKernelBinary")) { assert ptxCode.getTargetCode() != null; @@ -372,7 +347,7 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { return new PTXHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } @@ -392,7 +367,7 @@ asm.emitString(""); // Get the start block - Block startBlock = lir.cfg.getStartBlock(); + Block startBlock = lir.getControlFlowGraph().getStartBlock(); // Keep a list of ParameterOp instructions to delete from the // list of instructions in the block. ArrayList deleteOps = new ArrayList<>(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackendFactory.java Mon Mar 17 14:30:59 2014 +0100 @@ -59,7 +59,7 @@ final int stackFrameAlignment = 1; final int implicitNullCheckLimit = 0; final boolean inlineObjects = true; - return new TargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); } public String getArchitecture() { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Mon Mar 17 14:30:59 2014 +0100 @@ -133,7 +133,7 @@ if (locations[i] == null) { locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -72,8 +72,8 @@ } @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { - return new SPARCHotSpotLIRGenerator(graph, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); + public LIRGenerator newLIRGenerator(StructuredGraph graph, Object stub, FrameMap frameMap, CallingConvention cc, LIR lir) { + return new SPARCHotSpotLIRGenerator(graph, stub, getProviders(), getRuntime().getConfig(), frameMap, cc, lir); } /** diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Mon Mar 17 14:30:59 2014 +0100 @@ -42,7 +42,7 @@ final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; - return new TargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + return new HotSpotTargetDescription(createArchitecture(), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects, Kind.Int); } public HotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotBackend host) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCodeCacheProvider.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCodeCacheProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCodeCacheProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -34,6 +34,6 @@ @Override protected RegisterConfig createRegisterConfig() { - return new SPARCHotSpotRegisterConfig(getTarget().arch, runtime.getConfig()); + return new SPARCHotSpotRegisterConfig(getTarget(), runtime.getConfig()); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -51,10 +51,12 @@ public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSpotLIRGenerator { private final HotSpotVMConfig config; + private final Object stub; - public SPARCHotSpotLIRGenerator(StructuredGraph graph, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { + public SPARCHotSpotLIRGenerator(StructuredGraph graph, Object stub, HotSpotProviders providers, HotSpotVMConfig config, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); this.config = config; + this.stub = stub; } @Override @@ -84,23 +86,19 @@ @Override protected boolean needOnlyOopMaps() { // Stubs only need oop maps - return graph.start() instanceof StubStartNode; + return stub != null; } Stub getStub() { - if (graph.start() instanceof StubStartNode) { - return ((StubStartNode) graph.start()).getStub(); - } - return null; + return (Stub) stub; } @Override public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) { - Stub stub = getStub(); Variable result; if (linkage.canDeoptimize()) { - assert info != null || stub != null; + assert info != null || getStub() != null; HotSpotRegistersProvider registers = getProviders().getRegisters(); Register thread = registers.getThreadRegister(); Register stackPointer = registers.getStackPointerRegister(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotRegisterConfig.java Mon Mar 17 14:30:59 2014 +0100 @@ -130,10 +130,10 @@ return registers; } - public SPARCHotSpotRegisterConfig(Architecture architecture, HotSpotVMConfig config) { - this.architecture = architecture; + public SPARCHotSpotRegisterConfig(TargetDescription target, HotSpotVMConfig config) { + this.architecture = target.arch; - csl = new CalleeSaveLayout(architecture, -1, -1, architecture.getWordSize(), calleeSaveRegisters); + csl = new CalleeSaveLayout(target, -1, -1, target.arch.getWordSize(), calleeSaveRegisters); allocatable = initAllocatable(config.useCompressedOops); attributesMap = RegisterAttributes.createMap(this, SPARC.allRegisters); } @@ -203,7 +203,7 @@ if (locations[i] == null) { locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -204,8 +204,8 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler final Suites suitesLocal = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites(); - final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + final CompilationResult compResult = compileGraph(graph, null, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), + OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, new CompilationResult(), CompilationResultBuilderFactory.Default); addMethod(method, compResult); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotCryptoSubstitutionTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -49,7 +49,7 @@ protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) { HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; HotSpotNmethod installedCode = new HotSpotNmethod(hsMethod, compResult.getName(), true); - HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(runtime().getTarget().arch, hsMethod, compResult); + HotSpotCompiledNmethod compiledNmethod = new HotSpotCompiledNmethod(runtime().getTarget(), hsMethod, compResult); CodeInstallResult result = runtime().getCompilerToVM().installCode(compiledNmethod, installedCode, null); Assert.assertEquals("Error installing method " + method + ": " + result, result, CodeInstallResult.OK); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java Mon Mar 17 14:30:59 2014 +0100 @@ -102,10 +102,10 @@ } } - public void finish(HotSpotResolvedJavaMethod method) { + public void finish(HotSpotResolvedJavaMethod method, HotSpotInstalledCode code) { if (ENABLED) { duration = System.nanoTime() - startTime; - codeSize = method.getCompiledCodeSize(); + codeSize = (int) code.getCodeSize(); memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart; if (current.get().getLast() != this) { throw new RuntimeException("mismatch in finish()"); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Mon Mar 17 14:30:59 2014 +0100 @@ -32,6 +32,7 @@ import java.io.*; import java.lang.reflect.*; +import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -53,6 +54,8 @@ public class CompilationTask implements Runnable, Comparable { + private static final long TIMESTAMP_START = System.currentTimeMillis(); + // Keep static finals in a group with withinEnqueue as the last one. CompilationTask can be // called from within it's own clinit so it needs to be careful about accessing state. Once // withinEnqueue is non-null we assume that CompilationTask is fully initialized. @@ -130,9 +133,6 @@ try { runCompilation(true); } finally { - if (method.currentTask() == this) { - method.setCurrentTask(null); - } withinEnqueue.set(Boolean.TRUE); status.set(CompilationStatus.Finished); synchronized (this) { @@ -237,9 +237,9 @@ TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); long start = System.currentTimeMillis(); try (Scope s = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(id), true))) { - GraphCache graphCache = backend.getRuntime().getGraphCache(); - if (graphCache != null) { - graphCache.removeStaleGraphs(); + Map graphCache = null; + if (GraalOptions.CacheGraphs.getValue()) { + graphCache = new HashMap<>(); } HotSpotProviders providers = backend.getProviders(); @@ -263,8 +263,8 @@ Suites suites = getSuites(providers); ProfilingInfo profilingInfo = getProfilingInfo(); OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo); - result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, - method.getSpeculationLog(), suites, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + result = compileGraph(graph, null, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, + method.getSpeculationLog(), suites, new CompilationResult(), CompilationResultBuilderFactory.Default); result.setId(getId()); result.setEntryBCI(entryBCI); } catch (Throwable e) { @@ -281,8 +281,12 @@ try (TimerCloseable b = CodeInstallationTime.start()) { installedCode = installMethod(result); + if (!isOSR) { + ProfilingInfo profile = method.getProfilingInfo(); + profile.setCompilerIRSize(StructuredGraph.class, graph.getNodeCount()); + } } - stats.finish(method); + stats.finish(method, installedCode); } catch (BailoutException bailout) { BAILOUTS.increment(); if (ExitVMOnBailout.getValue()) { @@ -328,7 +332,24 @@ private void printCompilation() { final boolean isOSR = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; final int mod = method.getModifiers(); - TTY.println(String.format("%7d %4d %c%c%c%c%c %s %s(%d bytes)", 0, id, isOSR ? '%' : ' ', Modifier.isSynchronized(mod) ? 's' : ' ', ' ', ' ', Modifier.isNative(mod) ? 'n' : ' ', + String compilerName = ""; + if (HotSpotCIPrintCompilerName.getValue()) { + compilerName = "Graal:"; + } + HotSpotVMConfig config = backend.getRuntime().getConfig(); + int compLevel = config.compilationLevelFullOptimization; + char compLevelChar; + if (config.tieredCompilation) { + compLevelChar = '-'; + if (compLevel != -1) { + compLevelChar = (char) ('0' + compLevel); + } + } else { + compLevelChar = ' '; + } + boolean hasExceptionHandlers = method.getExceptionHandlers().length > 0; + TTY.println(String.format("%s%7d %4d %c%c%c%c%c%c %s %s(%d bytes)", compilerName, (System.currentTimeMillis() - TIMESTAMP_START), id, isOSR ? '%' : ' ', + Modifier.isSynchronized(mod) ? 's' : ' ', hasExceptionHandlers ? '!' : ' ', blocking ? 'b' : ' ', Modifier.isNative(mod) ? 'n' : ' ', compLevelChar, MetaUtil.format("%H::%n(%p)", method), isOSR ? "@ " + entryBCI + " " : "", method.getCodeSize())); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,13 +27,13 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.GraphProducer; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.stubs.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.LIRInstruction.*; -import com.oracle.graal.lir.StandardOp.*; +import com.oracle.graal.lir.LIRInstruction.ValueProcedure; +import com.oracle.graal.lir.StandardOp.LabelOp; +import com.oracle.graal.lir.StandardOp.SaveRegistersOp; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.phases.tiers.*; @@ -95,14 +95,6 @@ } /** - * Gets the graph producer provided by this backend (if any). A primary use case for this is a - * GPU backend that may want to offload certain methods to the GPU. - */ - public GraphProducer getGraphProducer() { - return null; - } - - /** * Finds all the registers that are defined by some given LIR. * * @param lir the LIR to examine diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledCode.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,21 +22,17 @@ */ package com.oracle.graal.hotspot; -import java.nio.*; import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CompilationResult.CodeAnnotation; import com.oracle.graal.api.code.CompilationResult.CodeComment; -import com.oracle.graal.api.code.CompilationResult.Data; -import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.code.CompilationResult.ExceptionHandler; import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.CompilationResult.JumpTable; import com.oracle.graal.api.code.CompilationResult.Mark; import com.oracle.graal.api.code.CompilationResult.Site; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; +import com.oracle.graal.hotspot.data.*; /** * A {@link CompilationResult} with additional HotSpot-specific information required for installing @@ -53,111 +49,6 @@ public final DataSection dataSection; - /** - * Represents a reference to the data section. Before the code is installed, all {@link Data} - * items referenced by a {@link DataPatch} are put into the data section of the method, and - * replaced by {@link HotSpotData}. - */ - public static final class HotSpotData extends Data { - - /** - * The offset of the data item in the data section. - */ - public int offset; - - /** - * If the data item is an oop that needs to be patched by the runtime, this field contains - * the reference to the object. - */ - public Constant constant; - - public HotSpotData(int offset) { - super(0); - this.offset = offset; - } - - @Override - public int getSize(Architecture arch) { - return 0; - } - - @Override - public void emit(Architecture arch, ByteBuffer buffer) { - } - } - - /** - * Represents the data section of a method. - */ - public static final class DataSection { - - /** - * The minimum alignment required for this data section. - */ - public final int sectionAlignment; - - /** - * The raw data contained in the data section. - */ - public final byte[] data; - - /** - * A list of locations where oop pointers need to be patched by the runtime. - */ - public final HotSpotData[] patches; - - public DataSection(Architecture arch, Site[] sites) { - int size = 0; - int patchCount = 0; - List externalDataList = new ArrayList<>(); - - // find all external data items and determine total size of data section - for (Site site : sites) { - if (site instanceof DataPatch) { - DataPatch dataPatch = (DataPatch) site; - if (dataPatch.externalData != null) { - Data d = dataPatch.externalData; - size = NumUtil.roundUp(size, d.getAlignment()); - size += d.getSize(arch); - externalDataList.add(dataPatch); - if (dataPatch.getConstant() != null && dataPatch.getConstant().getKind() == Kind.Object) { - patchCount++; - } - } - } - } - - data = new byte[size]; - patches = new HotSpotData[patchCount]; - ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.nativeOrder()); - int index = 0; - int patchIndex = 0; - int alignment = 0; - - // build data section - for (DataPatch dataPatch : externalDataList) { - Data d = dataPatch.externalData; - - alignment = Math.max(alignment, d.getAlignment()); - index = NumUtil.roundUp(index, d.getAlignment()); - buffer.position(index); - - HotSpotData hsData = new HotSpotData(index); - if (dataPatch.getConstant() != null && dataPatch.getConstant().getKind() == Kind.Object) { - // record patch location for oop pointers - hsData.constant = dataPatch.getConstant(); - patches[patchIndex++] = hsData; - } - dataPatch.externalData = hsData; - - index += d.getSize(arch); - d.emit(arch, buffer); - } - - this.sectionAlignment = alignment; - } - } - public static class Comment { public final String text; @@ -169,10 +60,10 @@ } } - public HotSpotCompiledCode(Architecture arch, CompilationResult compResult) { + public HotSpotCompiledCode(TargetDescription target, CompilationResult compResult) { this.comp = compResult; sites = getSortedSites(compResult); - dataSection = new DataSection(arch, sites); + dataSection = new DataSection(target, sites); if (compResult.getExceptionHandlers().isEmpty()) { exceptionHandlers = null; } else { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledNmethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -35,8 +35,8 @@ public final int entryBCI; public final int id; - public HotSpotCompiledNmethod(Architecture arch, HotSpotResolvedJavaMethod method, CompilationResult compResult) { - super(arch, compResult); + public HotSpotCompiledNmethod(TargetDescription target, HotSpotResolvedJavaMethod method, CompilationResult compResult) { + super(target, compResult); this.method = method; this.entryBCI = compResult.getEntryBCI(); this.id = compResult.getId(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotCompiledRuntimeStub.java Mon Mar 17 14:30:59 2014 +0100 @@ -26,7 +26,7 @@ import com.oracle.graal.api.code.CompilationResult.Call; import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.code.CompilationResult.Infopoint; -import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.data.*; import com.oracle.graal.hotspot.stubs.*; /** @@ -38,8 +38,8 @@ public final String stubName; - public HotSpotCompiledRuntimeStub(Architecture arch, Stub stub, CompilationResult compResult) { - super(arch, compResult); + public HotSpotCompiledRuntimeStub(TargetDescription target, Stub stub, CompilationResult compResult) { + super(target, compResult); assert checkStubInvariants(compResult); this.stubName = stub.toString(); } @@ -50,11 +50,7 @@ private boolean checkStubInvariants(CompilationResult compResult) { assert compResult.getExceptionHandlers().isEmpty(); for (DataPatch data : compResult.getDataReferences()) { - Constant constant = data.getConstant(); - if (constant != null) { - assert constant.getKind() != Kind.Object : this + " cannot have embedded object constant: " + constant; - assert constant.getPrimitiveAnnotation() == null : this + " cannot have embedded metadata: " + constant; - } + assert !(data.data instanceof PatchedData) : this + " cannot have embedded object or metadata constant: " + data.data; } for (Infopoint infopoint : compResult.getInfopoints()) { assert infopoint instanceof Call : this + " cannot have non-call infopoint: " + infopoint; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Mon Mar 17 14:30:59 2014 +0100 @@ -30,6 +30,7 @@ import java.util.*; import sun.misc.*; +import sun.reflect.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -40,7 +41,6 @@ import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.options.*; -import com.oracle.graal.phases.*; import com.oracle.graal.runtime.*; //JaCoCo Exclude @@ -58,11 +58,23 @@ /** * Gets the singleton {@link HotSpotGraalRuntime} object. */ + @CallerSensitive public static HotSpotGraalRuntime runtime() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + Class cc = Reflection.getCallerClass(); + if (cc != null && cc.getClassLoader() != null) { + sm.checkPermission(Graal.ACCESS_PERMISSION); + } + } assert instance != null; return instance; } + static { + Reflection.registerFieldsToFilter(HotSpotGraalRuntime.class, "instance"); + } + /** * Do deferred initialization. */ @@ -183,8 +195,6 @@ protected/* final */CompilerToVM compilerToVm; protected/* final */VMToCompiler vmToCompiler; - private volatile HotSpotGraphCache cache; - protected final HotSpotVMConfig config; private final HotSpotBackend hostBackend; @@ -225,6 +235,9 @@ if (HotSpotPrintInlining.getValue() == false) { HotSpotPrintInlining.setValue(config.printInlining); } + if (HotSpotCIPrintCompilerName.getValue() == false) { + HotSpotCIPrintCompilerName.setValue(config.printCompilerName); + } if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { printConfig(config); @@ -241,10 +254,6 @@ } registerBackend(factory.createBackend(this, hostBackend)); } - - if (GraalOptions.CacheGraphs.getValue()) { - cache = new HotSpotGraphCache(compilerToVm); - } } private HotSpotBackend registerBackend(HotSpotBackend backend) { @@ -301,10 +310,6 @@ return hostBackend.getTarget(); } - public HotSpotGraphCache getGraphCache() { - return cache; - } - public CompilerToVM getCompilerToVM() { return compilerToVm; } @@ -318,13 +323,13 @@ * * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format * @param accessingType the context of resolution (may be null) - * @param eagerResolve force resolution to a {@link ResolvedJavaType}. If true, this method will + * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will * either return a {@link ResolvedJavaType} or throw an exception * @return a Java type for {@code name} which is guaranteed to be of type - * {@link ResolvedJavaType} if {@code eagerResolve == true} - * @throws LinkageError if {@code eagerResolve == true} and the resolution failed + * {@link ResolvedJavaType} if {@code resolve == true} + * @throws LinkageError if {@code resolve == true} and the resolution failed */ - public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean eagerResolve) { + public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { // If the name represents a primitive type we can short-circuit the lookup. if (name.length() == 1) { Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); @@ -338,7 +343,7 @@ } // Resolve the type in the VM. - final long metaspaceKlass = compilerToVm.lookupType(name, accessingClass, eagerResolve); + final long metaspaceKlass = compilerToVm.lookupType(name, accessingClass, resolve); if (metaspaceKlass == 0) { return HotSpotUnresolvedJavaType.create(name); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Mon Mar 17 14:30:59 2014 +0100 @@ -26,12 +26,10 @@ import java.util.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.hotspot.HotSpotReplacementsImpl.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.spi.*; @@ -60,8 +58,6 @@ lowerer.initialize(providers, config); HotSpotReplacementsImpl replacements = (HotSpotReplacementsImpl) providers.getReplacements(); - replacements.registerGraphProducers(getNonHostGraphProducers()); - // Install intrinsics. if (Intrinsify.getValue()) { try (Scope s = Debug.scope("RegisterReplacements", new DebugDumpScope("RegisterReplacements"))) { @@ -81,26 +77,4 @@ } } - - /** - * Gets the {@link GraphProducer}s from the non-host backends. These allow a GPU backend (for - * example) to offload compilation and execution of certain methods to a GPU. - *

    - * Note that is is a very rough initial attempt at providing a hook for a GPU backend to - * intercept a compilation (or method inlining) for the purpose of routing execution to the GPU. - * Expect it to be extensively refined as experimentation with GPU offload proceeds. - */ - protected GraphProducer[] getNonHostGraphProducers() { - List list = new ArrayList<>(); - for (Map.Entry, HotSpotBackend> e : getRuntime().getBackends().entrySet()) { - HotSpotBackend value = e.getValue(); - if (value != this) { - GraphProducer gp = value.getGraphProducer(); - if (gp != null) { - list.add(gp); - } - } - } - return list.toArray(new GraphProducer[list.size()]); - } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReferenceMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot; + +import java.io.*; +import java.util.*; + +import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; + +public class HotSpotReferenceMap implements ReferenceMap, Serializable { + + private static final long serialVersionUID = -1052183095979496819L; + + /** + * Contains 2 bits per register. + *

      + *
    • bit0 = 0: contains no references
    • + *
    • bit0 = 1, bit1 = 0: contains a wide oop
    • + *
    • bit0 = 1, bit1 = 1: contains a narrow oop
    • + *
    + */ + private final BitSet registerRefMap; + + /** + * Contains 3 bits per stack slot. + *
      + *
    • bit0 = 0: contains no references
    • + *
    • bit0 = 1, bit1+2 = 0: contains a wide oop
    • + *
    • bit0 = 1, bit1 = 1: contains a narrow oop in the lower half
    • + *
    • bit0 = 1, bit2 = 1: contains a narrow oop in the upper half
    • + *
    + */ + private final BitSet frameRefMap; + + private final int frameSlotSize; + + public HotSpotReferenceMap(int registerCount, int frameSlotCount, int frameSlotSize) { + if (registerCount > 0) { + this.registerRefMap = new BitSet(registerCount * 2); + } else { + this.registerRefMap = null; + } + this.frameRefMap = new BitSet(frameSlotCount * 3); + this.frameSlotSize = frameSlotSize; + } + + public void setRegister(int idx, PlatformKind kind) { + if (kind == Kind.Object) { + registerRefMap.set(2 * idx); + } else if (kind == NarrowOopStamp.NarrowOop) { + registerRefMap.set(2 * idx); + registerRefMap.set(2 * idx + 1); + } + } + + public void setStackSlot(int offset, PlatformKind kind) { + int idx = offset / frameSlotSize; + if (kind == Kind.Object) { + assert offset % frameSlotSize == 0; + frameRefMap.set(3 * idx); + } else if (kind == NarrowOopStamp.NarrowOop) { + frameRefMap.set(3 * idx); + if (offset % frameSlotSize == 0) { + frameRefMap.set(3 * idx + 1); + } else { + assert offset % frameSlotSize == frameSlotSize / 2; + frameRefMap.set(3 * idx + 2); + } + } + } + + public boolean hasRegisterRefMap() { + return registerRefMap != null && registerRefMap.size() > 0; + } + + public boolean hasFrameRefMap() { + return frameRefMap != null && frameRefMap.size() > 0; + } + + public void appendRegisterMap(StringBuilder sb, RefMapFormatter formatter) { + for (int reg = registerRefMap.nextSetBit(0); reg >= 0; reg = registerRefMap.nextSetBit(reg + 2)) { + sb.append(' ').append(formatter.formatRegister(reg / 2)); + } + } + + public void appendFrameMap(StringBuilder sb, RefMapFormatter formatter) { + for (int slot = frameRefMap.nextSetBit(0); slot >= 0; slot = frameRefMap.nextSetBit(slot + 3)) { + sb.append(' ').append(formatter.formatStackSlot(slot / 3)); + } + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotReplacementsImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -80,41 +80,6 @@ return super.registerMethodSubstitution(originalMethod, substituteMethod); } - /** - * A producer of graphs for methods. - */ - public interface GraphProducer { - - /** - * @returns a graph for {@code method} or null - */ - StructuredGraph getGraphFor(ResolvedJavaMethod method); - } - - /** - * Registers the graph producers that will take precedence over the registered method - * substitutions when {@link #getMethodSubstitution(ResolvedJavaMethod)} is called. - */ - public void registerGraphProducers(GraphProducer[] producers) { - assert this.graphProducers == UNINITIALIZED : "graph producers must be registered at most once"; - this.graphProducers = producers.clone(); - } - - private static GraphProducer[] UNINITIALIZED = {}; - - private GraphProducer[] graphProducers = UNINITIALIZED; - - @Override - public StructuredGraph getMethodSubstitution(ResolvedJavaMethod original) { - for (GraphProducer gp : graphProducers) { - StructuredGraph graph = gp.getGraphFor(original); - if (graph != null) { - return graph; - } - } - return super.getMethodSubstitution(original); - } - @Override public Class getMacroSubstitution(ResolvedJavaMethod method) { HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetDescription.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.nodes.type.*; + +public class HotSpotTargetDescription extends TargetDescription { + + private final PlatformKind rawNarrowOopKind; + + public HotSpotTargetDescription(Architecture arch, boolean isMP, int stackAlignment, int implicitNullCheckLimit, boolean inlineObjects, PlatformKind rawNarrowOopKind) { + super(arch, isMP, stackAlignment, implicitNullCheckLimit, inlineObjects); + this.rawNarrowOopKind = rawNarrowOopKind; + } + + @Override + public int getSizeInBytes(PlatformKind kind) { + if (kind == NarrowOopStamp.NarrowOop) { + return super.getSizeInBytes(rawNarrowOopKind); + } else { + return super.getSizeInBytes(kind); + } + } + + @Override + public ReferenceMap createReferenceMap(boolean hasRegisters, int stackSlotCount) { + return new HotSpotReferenceMap(hasRegisters ? arch.getRegisterReferenceMapBitCount() : 0, stackSlotCount, wordSize); + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Mon Mar 17 14:30:59 2014 +0100 @@ -60,8 +60,19 @@ } HotSpotVMConfig(CompilerToVM compilerToVm) { + /** These fields are set in {@link CompilerToVM#initializeConfiguration}. */ + gHotSpotVMStructs = 0; + gHotSpotVMTypes = 0; + gHotSpotVMIntConstants = 0; + gHotSpotVMLongConstants = 0; + compilerToVm.initializeConfiguration(this); + assert gHotSpotVMStructs != 0; + assert gHotSpotVMTypes != 0; + assert gHotSpotVMIntConstants != 0; + assert gHotSpotVMLongConstants != 0; + // Fill the VM fields hash map. HashMap vmFields = new HashMap<>(); for (VMFields.Field e : new VMFields(gHotSpotVMStructs)) { @@ -698,10 +709,12 @@ @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; @HotSpotVMFlag(name = "PrintCompilation") @Stable public boolean printCompilation; + @HotSpotVMFlag(name = "CIPrintCompilerName") @Stable public boolean printCompilerName; @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking; @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; @HotSpotVMFlag(name = "GPUOffload") @Stable public boolean gpuOffload; + @HotSpotVMFlag(name = "TieredCompilation") @Stable public boolean tieredCompilation; @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; @HotSpotVMFlag(name = "UseBiasedLocking") @Stable public boolean useBiasedLocking; @@ -1178,6 +1191,7 @@ @HotSpotVMField(name = "MethodData::_data_size", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataDataSize; @HotSpotVMField(name = "MethodData::_data[0]", type = "intptr_t", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopDataOffset; @HotSpotVMField(name = "MethodData::_trap_hist._array[0]", type = "u1", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOopTrapHistoryOffset; + @HotSpotVMField(name = "MethodData::_graal_node_count", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataGraalNodeCountOffset; @HotSpotVMField(name = "nmethod::_verified_entry_point", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodEntryOffset; @HotSpotVMField(name = "nmethod::_comp_level", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int nmethodCompLevelOffset; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Mon Mar 17 14:30:59 2014 +0100 @@ -59,7 +59,7 @@ * Determines if a given metaspace Method can be inlined. A method may not be inlinable for a * number of reasons such as: *
      - *
    • a CompileOracle directive may prevent inlining or compilation of this methods
    • + *
    • a CompileOracle directive may prevent inlining or compilation of methods
    • *
    • the method may have a bytecode breakpoint set
    • *
    • the method may have other bytecode features that require special handling by the VM
    • *
    @@ -111,16 +111,16 @@ * * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format * @param accessingClass the context of resolution (may be null) - * @param eagerResolve force resolution to a {@link ResolvedJavaType}. If true, this method will + * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will * either return a {@link ResolvedJavaType} or throw an exception * @return a metaspace klass for {@code name} - * @throws LinkageError if {@code eagerResolve == true} and the resolution failed + * @throws LinkageError if {@code resolve == true} and the resolution failed */ - long lookupType(String name, Class accessingClass, boolean eagerResolve); + long lookupType(String name, Class accessingClass, boolean resolve); - long lookupKlassByName(String name, Class accessingClass); + Object resolveConstantInPool(long metaspaceConstantPool, int cpi); - Object lookupConstantInPool(long metaspaceConstantPool, int cpi); + Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); @@ -130,6 +130,8 @@ int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); + long constantPoolKlassAt(long metaspaceConstantPool, int cpi); + /** * Looks up a class entry in a constant pool. * @@ -165,7 +167,7 @@ */ long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); - void loadReferencedTypeInPool(long metaspaceConstantPool, int cpi, byte opcode); + int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); @@ -250,14 +252,6 @@ boolean hasFinalizableSubclass(long metaspaceKlass); /** - * Gets the compiled code size for a method. - * - * @param metaspaceMethod the metaspace Method object to query - * @return the compiled code size the method - */ - int getCompiledCodeSize(long metaspaceMethod); - - /** * Gets the metaspace Method object corresponding to a given {@link Class} object and slot * number. * @@ -277,8 +271,6 @@ Object executeCompiledMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException; - long[] getDeoptedLeafGraphIds(); - long[] getLineNumberTable(long metaspaceMethod); long getLocalVariableTableStart(long metaspaceMethod); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -63,11 +63,9 @@ @Override public native long lookupType(String name, Class accessingClass, boolean eagerResolve); - @Override - public native long lookupKlassByName(String name, Class accessingClass); + public native Object resolveConstantInPool(long metaspaceConstantPool, int cpi); - @Override - public native Object lookupConstantInPool(long metaspaceConstantPool, int cpi); + public native Object resolvePossiblyCachedConstantInPool(long metaspaceConstantPool, int cpi); @Override public native int lookupNameAndTypeRefIndexInPool(long metaspaceConstantPool, int cpi); @@ -81,6 +79,8 @@ @Override public native int lookupKlassRefIndexInPool(long metaspaceConstantPool, int cpi); + public native long constantPoolKlassAt(long metaspaceConstantPool, int cpi); + @Override public native long lookupKlassInPool(long metaspaceConstantPool, int cpi); @@ -90,8 +90,7 @@ @Override public native long resolveField(long metaspaceConstantPool, int cpi, byte opcode, long[] info); - @Override - public native void loadReferencedTypeInPool(long metaspaceConstantPool, int cpi, byte opcode); + public native int constantPoolRemapInstructionOperandFromCache(long metaspaceConstantPool, int cpi); @Override public native Object lookupAppendixInPool(long metaspaceConstantPool, int cpi); @@ -112,9 +111,6 @@ public native long getClassInitializer(long metaspaceKlass); @Override - public native int getCompiledCodeSize(long metaspaceMethod); - - @Override public native long getMaxCallTargetOffset(long address); // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage @@ -128,9 +124,6 @@ public native Object executeCompiledMethodVarargs(Object[] args, HotSpotInstalledCode hotspotInstalledCode); @Override - public native long[] getDeoptedLeafGraphIds(); - - @Override public native long[] getLineNumberTable(long metaspaceMethod); @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -330,9 +330,6 @@ TTY.println(" in %d ms (compiled %d methods)", System.currentTimeMillis() - startTime, compileQueue.getCompletedTaskCount()); } - if (runtime.getGraphCache() != null) { - runtime.getGraphCache().clear(); - } System.gc(); phaseTransition("bootstrap2"); } @@ -584,7 +581,6 @@ CompilationTask task = new CompilationTask(backend, method, entryBCI, block); try { - method.setCurrentTask(task); compileQueue.execute(task); if (block) { task.block(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSection.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.data; + +import java.nio.*; +import java.util.*; + +import com.oracle.graal.api.code.CompilationResult.Data; +import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.CompilationResult.Site; +import com.oracle.graal.api.code.*; +import com.oracle.graal.asm.*; + +/** + * Represents the data section of a method. + */ +public final class DataSection { + + /** + * The minimum alignment required for this data section. + */ + public final int sectionAlignment; + + /** + * The raw data contained in the data section. + */ + public final byte[] data; + + /** + * A list of locations where oop pointers need to be patched by the runtime. + */ + public final DataPatch[] patches; + + public DataSection(TargetDescription target, Site[] sites) { + int size = 0; + int patchCount = 0; + List externalDataList = new ArrayList<>(); + + // find all external data items and determine total size of data section + for (Site site : sites) { + if (site instanceof DataPatch) { + DataPatch dataPatch = (DataPatch) site; + Data d = dataPatch.data; + if (dataPatch.inline) { + assert d instanceof PatchedData : "unnecessary data patch"; + } else { + size = NumUtil.roundUp(size, d.getAlignment()); + size += d.getSize(target); + externalDataList.add(dataPatch); + if (d instanceof PatchedData) { + patchCount++; + } + } + } + } + + data = new byte[size]; + patches = new DataPatch[patchCount]; + ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.nativeOrder()); + int index = 0; + int patchIndex = 0; + int alignment = 0; + + // build data section + for (DataPatch dataPatch : externalDataList) { + assert !dataPatch.inline; + Data d = dataPatch.data; + + alignment = Math.max(alignment, d.getAlignment()); + index = NumUtil.roundUp(index, d.getAlignment()); + buffer.position(index); + + DataSectionReference reference = new DataSectionReference(index); + if (d instanceof PatchedData) { + // record patch location + patches[patchIndex++] = new DataPatch(index, d, true); + } + dataPatch.data = reference; + + index += d.getSize(target); + d.emit(target, buffer); + } + + this.sectionAlignment = alignment; + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSectionReference.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/DataSectionReference.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.data; + +import java.nio.*; + +import com.oracle.graal.api.code.CompilationResult.Data; +import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +/** + * Represents a reference to the data section. Before the code is installed, all {@link Data} items + * referenced by a {@link DataPatch} are put into the data section of the method, and replaced by + * {@link DataSectionReference}. + */ +public class DataSectionReference extends Data { + + public final int offset; + + protected DataSectionReference(int offset) { + super(0); + this.offset = offset; + } + + @Override + public int getSize(TargetDescription target) { + return 0; + } + + @Override + public Kind getKind() { + return Kind.Illegal; + } + + @Override + public void emit(TargetDescription target, ByteBuffer buffer) { + } + +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/MetaspaceData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/MetaspaceData.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.data; + +import java.nio.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; + +/** + * A data item that represents a metaspace pointer. + */ +public class MetaspaceData extends PatchedData { + + public final long value; + public final Object annotation; + public final boolean compressed; + + public MetaspaceData(int alignment, long value, Object annotation, boolean compressed) { + super(alignment); + assert annotation != null; + this.value = value; + this.annotation = annotation; + this.compressed = compressed; + } + + @Override + public int getSize(TargetDescription target) { + if (compressed) { + return target.getSizeInBytes(Kind.Int); + } else { + return target.getSizeInBytes(target.wordKind); + } + } + + @Override + public Kind getKind() { + return Kind.Long; + } + + @Override + public void emit(TargetDescription target, ByteBuffer buffer) { + switch (getSize(target)) { + case 4: + buffer.putInt((int) value); + break; + case 8: + buffer.putLong(value); + break; + default: + throw GraalInternalError.shouldNotReachHere("unexpected metaspace pointer size"); + } + } + + @Override + public String toString() { + return (compressed ? "NarrowPointer[0x" + Integer.toHexString((int) value) : "Pointer[0x" + Long.toHexString(value)) + "]{" + annotation + "}"; + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/OopData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/OopData.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.data; + +import java.nio.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.nodes.type.*; + +/** + * A data item that represents an oop value. + */ +public class OopData extends PatchedData { + + public final Object object; + public final boolean compressed; + + public OopData(int alignment, Object object, boolean compressed) { + super(alignment); + this.object = object; + this.compressed = compressed; + } + + @Override + public int getSize(TargetDescription target) { + if (compressed) { + return target.getSizeInBytes(NarrowOopStamp.NarrowOop); + } else { + return target.getSizeInBytes(Kind.Object); + } + } + + @Override + public Kind getKind() { + return Kind.Object; + } + + @Override + public void emit(TargetDescription target, ByteBuffer buffer) { + switch (getSize(target)) { + case 4: + buffer.putInt(0xDEADDEAD); + break; + case 8: + buffer.putLong(0xDEADDEADDEADDEADL); + break; + default: + throw GraalInternalError.shouldNotReachHere("unexpected oop size"); + } + } + + @Override + public String toString() { + return (compressed ? "NarrowOop[" : "Oop[") + Kind.Object.format(object) + "]"; + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/data/PatchedData.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.data; + +import com.oracle.graal.api.code.CompilationResult.Data; + +/** + * Represents a data item that needs to be patched. + */ +public abstract class PatchedData extends Data { + + protected PatchedData(int alignment) { + super(alignment); + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -29,14 +29,17 @@ import com.oracle.graal.api.code.CodeUtil.DefaultRefMapFormatter; import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; import com.oracle.graal.api.code.CompilationResult.Call; +import com.oracle.graal.api.code.CompilationResult.Data; import com.oracle.graal.api.code.CompilationResult.DataPatch; import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.CompilationResult.Mark; +import com.oracle.graal.api.code.CompilationResult.PrimitiveData; import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult; +import com.oracle.graal.hotspot.data.*; import com.oracle.graal.java.*; import com.oracle.graal.printer.*; @@ -82,7 +85,7 @@ } } for (DataPatch site : compResult.getDataReferences()) { - hcf.addOperandComment(site.pcOffset, "{" + site.getDataString() + "}"); + hcf.addOperandComment(site.pcOffset, "{" + site.data.toString() + "}"); } for (Mark mark : compResult.getMarks()) { hcf.addComment(mark.pcOffset, getMarkName(mark)); @@ -173,7 +176,7 @@ compResult.setId(method.allocateCompileId(compResult.getEntryBCI())); } HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), true); - runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target.arch, method, compResult), installedCode, method.getSpeculationLog()); + runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target, method, compResult), installedCode, method.getSpeculationLog()); return logOrDump(installedCode, compResult); } @@ -184,7 +187,7 @@ compResult.setId(hotspotMethod.allocateCompileId(compResult.getEntryBCI())); } HotSpotInstalledCode code = new HotSpotNmethod(hotspotMethod, compResult.getName(), false); - CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target.arch, hotspotMethod, compResult), code, log); + CodeInstallResult result = runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(target, hotspotMethod, compResult), code, log); if (result != CodeInstallResult.OK) { return null; } @@ -203,7 +206,7 @@ compResult.setId(javaMethod.allocateCompileId(compResult.getEntryBCI())); } HotSpotNmethod code = new HotSpotNmethod(javaMethod, compResult.getName(), false, true); - HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(target.arch, javaMethod, compResult); + HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(target, javaMethod, compResult); CompilerToVM vm = runtime.getCompilerToVM(); CodeInstallResult result = vm.installCode(compiled, code, null); if (result != CodeInstallResult.OK) { @@ -216,6 +219,16 @@ return constant.getPrimitiveAnnotation() != null; } + public Data createDataItem(Constant constant, int alignment) { + if (constant.getPrimitiveAnnotation() != null) { + return new MetaspaceData(alignment, constant.asLong(), constant.getPrimitiveAnnotation(), false); + } else if (constant.getKind().isObject()) { + return new OopData(alignment, constant.asObject(), false); + } else { + return new PrimitiveData(constant, alignment); + } + } + @Override public TargetDescription getTarget() { return target; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Mon Mar 17 14:30:59 2014 +0100 @@ -40,6 +40,51 @@ private static final long serialVersionUID = -5443206401485234850L; /** + * Enum of all {@code JVM_CONSTANT} constants used in the VM. This includes the public and + * internal ones. + */ + private enum JVM_CONSTANT { + // @formatter:off + Utf8(config().jvmConstantUtf8), + Integer(config().jvmConstantInteger), + Long(config().jvmConstantLong), + Float(config().jvmConstantFloat), + Double(config().jvmConstantDouble), + Class(config().jvmConstantClass), + UnresolvedClass(config().jvmConstantUnresolvedClass), + UnresolvedClassInError(config().jvmConstantUnresolvedClassInError), + String(config().jvmConstantString), + Fieldref(config().jvmConstantFieldref), + MethodRef(config().jvmConstantMethodref), + InterfaceMethodref(config().jvmConstantInterfaceMethodref), + NameAndType(config().jvmConstantNameAndType), + MethodHandle(config().jvmConstantMethodHandle), + MethodHandleInError(config().jvmConstantMethodHandleInError), + MethodType(config().jvmConstantMethodType), + MethodTypeInError(config().jvmConstantMethodTypeInError); + // @formatter:on + + private final int value; + + private JVM_CONSTANT(int value) { + this.value = value; + } + + private static HotSpotVMConfig config() { + return runtime().getConfig(); + } + + public static JVM_CONSTANT getEnum(int value) { + for (JVM_CONSTANT e : values()) { + if (e.value == value) { + return e; + } + } + throw GraalInternalError.shouldNotReachHere("unknown enum value " + value); + } + } + + /** * Reference to the C++ ConstantPool object. */ private final long metaspaceConstantPool; @@ -53,7 +98,7 @@ * * @return holder for this constant pool */ - private HotSpotResolvedJavaType getHolder() { + private HotSpotResolvedObjectType getHolder() { final long metaspaceKlass = unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolHolderOffset); return (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); } @@ -86,11 +131,12 @@ * @param index constant pool index * @return constant pool tag */ - private int getTagAt(int index) { + private JVM_CONSTANT getTagAt(int index) { assertBounds(index); HotSpotVMConfig config = runtime().getConfig(); - long tags = unsafe.getAddress(metaspaceConstantPool + config.constantPoolTagsOffset); - return unsafe.getByteVolatile(null, tags + config.arrayU1DataOffset + index); + final long metaspaceConstantPoolTags = unsafe.getAddress(metaspaceConstantPool + config.constantPoolTagsOffset); + final int tag = unsafe.getByteVolatile(null, metaspaceConstantPoolTags + config.arrayU1DataOffset + index); + return JVM_CONSTANT.getEnum(tag); } /** @@ -101,8 +147,7 @@ */ private long getEntryAt(int index) { assertBounds(index); - HotSpotVMConfig config = runtime().getConfig(); - return unsafe.getAddress(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -112,9 +157,8 @@ * @return integer constant pool entry at index */ private int getIntAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); - assertTag(index, config.jvmConstantInteger); - return unsafe.getInt(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + assertTag(index, JVM_CONSTANT.Integer); + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -124,9 +168,8 @@ * @return long constant pool entry */ private long getLongAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); - assertTag(index, config.jvmConstantLong); - return unsafe.getLong(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + assertTag(index, JVM_CONSTANT.Long); + return unsafe.getLong(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -136,9 +179,8 @@ * @return float constant pool entry */ private float getFloatAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); - assertTag(index, config.jvmConstantFloat); - return unsafe.getFloat(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + assertTag(index, JVM_CONSTANT.Float); + return unsafe.getFloat(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -148,9 +190,8 @@ * @return float constant pool entry */ private double getDoubleAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); - assertTag(index, config.jvmConstantDouble); - return unsafe.getDouble(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + assertTag(index, JVM_CONSTANT.Double); + return unsafe.getDouble(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -160,9 +201,8 @@ * @return {@code JVM_CONSTANT_NameAndType} constant pool entry */ private int getNameAndTypeAt(int index) { - HotSpotVMConfig config = runtime().getConfig(); - assertTag(index, config.jvmConstantNameAndType); - return unsafe.getInt(metaspaceConstantPool + config.constantPoolSize + index * runtime().getTarget().wordSize); + assertTag(index, JVM_CONSTANT.NameAndType); + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); } /** @@ -239,6 +279,20 @@ } /** + * Gets the uncached klass reference index constant pool entry at index {@code index}. See: + * {@code ConstantPool::uncached_klass_ref_index_at}. + * + * @param index constant pool index + * @return klass reference index + */ + private int getUncachedKlassRefIndexAt(int index) { + assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref; + final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + // klass ref index is in the low 16-bits. + return refIndex & 0xFFFF; + } + + /** * Asserts that the constant pool index {@code index} is in the bounds of the constant pool. * * @param index constant pool index @@ -253,115 +307,52 @@ * @param index constant pool index * @param tag expected tag */ - private void assertTag(int index, int tag) { - assert getTagAt(index) == tag : "constant pool tag at index " + index + " is " + getNameForTag(getTagAt(index)) + " but expected " + getNameForTag(tag); - } - - private static String getNameForTag(int tag) { - HotSpotVMConfig config = runtime().getConfig(); - if (tag == config.jvmConstantUtf8) { - return "JVM_CONSTANT_Utf8"; - } - if (tag == config.jvmConstantInteger) { - return "JVM_CONSTANT_Integer"; - } - if (tag == config.jvmConstantLong) { - return "JVM_CONSTANT_Long"; - } - if (tag == config.jvmConstantFloat) { - return "JVM_CONSTANT_Float"; - } - if (tag == config.jvmConstantDouble) { - return "JVM_CONSTANT_Double"; - } - if (tag == config.jvmConstantClass) { - return "JVM_CONSTANT_Class"; - } - if (tag == config.jvmConstantUnresolvedClass) { - return "JVM_CONSTANT_UnresolvedClass"; - } - if (tag == config.jvmConstantUnresolvedClassInError) { - return "JVM_CONSTANT_UnresolvedClassInError"; - } - if (tag == config.jvmConstantString) { - return "JVM_CONSTANT_String"; - } - if (tag == config.jvmConstantFieldref) { - return "JVM_CONSTANT_Fieldref"; - } - if (tag == config.jvmConstantMethodref) { - return "JVM_CONSTANT_Methodref"; - } - if (tag == config.jvmConstantInterfaceMethodref) { - return "JVM_CONSTANT_InterfaceMethodref"; - } - if (tag == config.jvmConstantNameAndType) { - return "JVM_CONSTANT_NameAndType"; - } - if (tag == config.jvmConstantMethodHandle) { - return "JVM_CONSTANT_MethodHandle"; - } - if (tag == config.jvmConstantMethodHandleInError) { - return "JVM_CONSTANT_MethodHandleInError"; - } - if (tag == config.jvmConstantMethodType) { - return "JVM_CONSTANT_MethodType"; - } - if (tag == config.jvmConstantMethodTypeInError) { - return "JVM_CONSTANT_MethodTypeInError"; - } - return "unknown constant tag " + tag; + private void assertTag(int index, JVM_CONSTANT tag) { + assert getTagAt(index) == tag : "constant pool tag at index " + index + " is " + getTagAt(index) + " but expected " + tag; } @Override public int length() { - HotSpotVMConfig config = runtime().getConfig(); - return unsafe.getInt(metaspaceConstantPool + config.constantPoolLengthOffset); + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolLengthOffset); } @Override public Object lookupConstant(int cpi) { assert cpi != 0; - - HotSpotVMConfig config = runtime().getConfig(); - final int tag = getTagAt(cpi); - - // Handle primitive constant pool entries directly. - if (tag == config.jvmConstantInteger) { - return Constant.forInt(getIntAt(cpi)); - } - if (tag == config.jvmConstantLong) { - return Constant.forLong(getLongAt(cpi)); - } - if (tag == config.jvmConstantFloat) { - return Constant.forFloat(getFloatAt(cpi)); - } - if (tag == config.jvmConstantDouble) { - return Constant.forDouble(getDoubleAt(cpi)); + final JVM_CONSTANT tag = getTagAt(cpi); + switch (tag) { + case Integer: + return Constant.forInt(getIntAt(cpi)); + case Long: + return Constant.forLong(getLongAt(cpi)); + case Float: + return Constant.forFloat(getFloatAt(cpi)); + case Double: + return Constant.forDouble(getDoubleAt(cpi)); + case Class: + case UnresolvedClass: + case UnresolvedClassInError: + final int opcode = -1; // opcode is not used + return lookupType(cpi, opcode); + case String: + Object string = runtime().getCompilerToVM().resolvePossiblyCachedConstantInPool(metaspaceConstantPool, cpi); + return Constant.forObject(string); + case MethodHandle: + case MethodHandleInError: + case MethodType: + case MethodTypeInError: + Object obj = runtime().getCompilerToVM().resolveConstantInPool(metaspaceConstantPool, cpi); + return Constant.forObject(obj); + default: + throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + tag); } - - // All the other constant pool entries need special attention so we call down into the VM. - if (tag == config.jvmConstantClass || tag == config.jvmConstantUnresolvedClass || tag == config.jvmConstantUnresolvedClassInError) { - final int opcode = -1; // opcode is not used - return lookupType(cpi, opcode); - } - if (tag == config.jvmConstantString) { - Object string = runtime().getCompilerToVM().lookupConstantInPool(metaspaceConstantPool, cpi); - return Constant.forObject(string); - } - if (tag == config.jvmConstantMethodHandle || tag == config.jvmConstantMethodHandleInError || tag == config.jvmConstantMethodType || tag == config.jvmConstantMethodTypeInError) { - Object obj = runtime().getCompilerToVM().lookupConstantInPool(metaspaceConstantPool, cpi); - return Constant.forObject(obj); - } - - throw GraalInternalError.shouldNotReachHere("unknown constant pool tag " + tag); } @Override public String lookupUtf8(int cpi) { - assertTag(cpi, runtime().getConfig().jvmConstantUtf8); - long signature = getEntryAt(cpi); - HotSpotSymbol symbol = new HotSpotSymbol(signature); + assertTag(cpi, JVM_CONSTANT.Utf8); + final long metaspaceSymbol = getEntryAt(cpi); + HotSpotSymbol symbol = new HotSpotSymbol(metaspaceSymbol); return symbol.asString(); } @@ -431,19 +422,7 @@ String name = lookupUtf8(nameIndex); final int typeIndex = getSignatureRefIndexAt(nameAndTypeIndex); String typeName = lookupUtf8(typeIndex); - - Kind kind = Kind.fromTypeString(typeName); - JavaType type; - if (kind.isPrimitive()) { - type = HotSpotResolvedPrimitiveType.fromKind(kind); - } else { - final long metaspaceKlass = runtime().getCompilerToVM().lookupKlassByName(typeName, getHolder().mirror()); - if (metaspaceKlass == 0L) { - type = HotSpotUnresolvedJavaType.create(typeName); - } else { - type = HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); - } - } + JavaType type = runtime().lookupType(typeName, getHolder(), false); final int holderIndex = getKlassRefIndexAt(index); JavaType holder = lookupType(holderIndex, opcode); @@ -485,7 +464,37 @@ break; default: index = toConstantPoolIndex(cpi, opcode); + index = runtime().getCompilerToVM().constantPoolRemapInstructionOperandFromCache(metaspaceConstantPool, index); } - runtime().getCompilerToVM().loadReferencedTypeInPool(metaspaceConstantPool, index, (byte) opcode); + + JVM_CONSTANT tag = getTagAt(index); + switch (tag) { + case Fieldref: + case MethodRef: + case InterfaceMethodref: + index = getUncachedKlassRefIndexAt(index); + tag = getTagAt(index); + assert tag == JVM_CONSTANT.Class || tag == JVM_CONSTANT.UnresolvedClass || tag == JVM_CONSTANT.UnresolvedClassInError : tag; + break; + default: + // nothing + break; + } + + switch (tag) { + case Class: + case UnresolvedClass: + case UnresolvedClassInError: + final long metaspaceKlass = runtime().getCompilerToVM().constantPoolKlassAt(metaspaceConstantPool, index); + HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) HotSpotResolvedObjectType.fromMetaspaceKlass(metaspaceKlass); + Class klass = type.mirror(); + if (!klass.isPrimitive() && !klass.isArray()) { + unsafe.ensureClassInitialized(klass); + } + break; + default: + // nothing + break; + } } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotForeignCallsProviderImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotForeignCallsProviderImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotForeignCallsProviderImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -134,8 +134,8 @@ public static final LocationIdentity[] NO_LOCATIONS = {}; public HotSpotForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) { + assert foreignCalls != null : descriptor; HotSpotForeignCallLinkage callTarget = foreignCalls.get(descriptor); - assert foreignCalls != null : descriptor; callTarget.finalizeAddress(runtime.getHostBackend()); return callTarget; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphCache.java Mon Mar 17 14:29:45 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot.meta; - -import static com.oracle.graal.phases.GraalOptions.*; - -import java.io.*; -import java.lang.ref.*; -import java.util.*; -import java.util.Map.Entry; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.bridge.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.spi.*; - -/** - * This class implements the graph caching system for the HotSpot platform. - * - * This implementation does not use a map to store the actual cached graphs. The problem is that - * such maps keep the graph, and therefore the {@link ResolvedJavaMethod} referenced from the graph, - * alive. For some applications and benchmarks this is a problem, e.g., the DaCapoScala "scalatest" - * benchmark will quickly run out of perm gen because of this. - * - * This cannot be solved with a {@code WeakHashMap}, since the values - * within the map will keep the keys alive. In order for this to work we would require a weak map in - * which the "strongness" of the value references depends upon the reachability of the keys. - * - * Therefore the graph cache is implemented in such a way that it stores its cache entries within - * the {@link ResolvedJavaMethod}. It uses the {@link ResolvedJavaMethod#getCompilerStorage()} map - * with the HotSpotGraphCache instance as key. The cached graph will be kept alive as long as the - * {@link ResolvedJavaMethod} is alive, but does not prevent the method, and therefore the class, - * from being unloaded. - * - * The {@link #cachedGraphIds} map is used to find the graphs that should be removed because of - * deoptimization, and to enforce the graph cache size restriction. - */ -public class HotSpotGraphCache implements GraphCache { - - private static final PrintStream out = System.out; - - private volatile long hitCounter; - private volatile long missCounter; - private volatile long removeHitCounter; - private volatile long removeCounter; - private volatile long putCounter; - - /** - * An ordered hash map for looking up the methods corresponding to a specific graph id. It - * enforces the maximum graph cache size by removing the oldest (in insertion-order) element if - * the cache gets too big. - */ - private final class LRUCache extends LinkedHashMap> { - - private static final long serialVersionUID = -3973307040793397840L; - - public LRUCache() { - super(GraphCacheSize.getValue() * 2, 0.75f, false); - } - - @Override - protected boolean removeEldestEntry(Entry> eldest) { - if (size() > GraphCacheSize.getValue()) { - ResolvedJavaMethod method = eldest.getValue().get(); - if (method != null) { - StructuredGraph cachedGraph = (StructuredGraph) method.getCompilerStorage().get(HotSpotGraphCache.this); - if (cachedGraph != null && cachedGraph.graphId() == eldest.getKey()) { - method.getCompilerStorage().remove(HotSpotGraphCache.this); - } - } - return true; - } else { - return false; - } - } - } - - private final Map> cachedGraphIds = Collections.synchronizedMap(new LRUCache()); - - public HotSpotGraphCache(CompilerToVM compilerToVM) { - this.compilerToVM = compilerToVM; - if (PrintGraphCache.getValue()) { - Runtime.getRuntime().addShutdownHook(new Thread() { - - @Override - public void run() { - out.println("put: " + putCounter); - out.println("get hit: " + hitCounter); - out.println("get miss: " + missCounter); - out.println("remove hit: " + removeHitCounter); - out.println("remove miss: " + (removeCounter - removeHitCounter)); - } - }); - } - } - - @Override - public StructuredGraph get(ResolvedJavaMethod method) { - StructuredGraph result = (StructuredGraph) method.getCompilerStorage().get(this); - - if (PrintGraphCache.getValue()) { - if (result == null) { - missCounter++; - } else { - hitCounter++; - } - } - return result; - } - - @Override - public boolean put(StructuredGraph graph, boolean hasMatureProfilingInfo) { - assert graph.method() != null; - if (hasMatureProfilingInfo) { - cachedGraphIds.put(graph.graphId(), new WeakReference<>(graph.method())); - graph.method().getCompilerStorage().put(this, graph); - - if (PrintGraphCache.getValue()) { - putCounter++; - } - return true; - } - return false; - } - - public void clear() { - synchronized (cachedGraphIds) { - for (WeakReference ref : cachedGraphIds.values()) { - ResolvedJavaMethod method = ref.get(); - if (method != null) { - method.getCompilerStorage().remove(this); - } - } - cachedGraphIds.clear(); - hitCounter = 0; - missCounter = 0; - removeHitCounter = 0; - removeCounter = 0; - putCounter = 0; - } - } - - public void removeGraphs(long[] deoptedGraphs) { - for (long graphId : deoptedGraphs) { - WeakReference ref = cachedGraphIds.get(graphId); - ResolvedJavaMethod method = ref == null ? null : ref.get(); - if (method != null) { - StructuredGraph cachedGraph = (StructuredGraph) method.getCompilerStorage().get(this); - if (cachedGraph != null && cachedGraph.graphId() == graphId) { - method.getCompilerStorage().remove(this); - if (PrintGraphCache.getValue()) { - removeHitCounter++; - } - } - } - if (PrintGraphCache.getValue()) { - removeCounter++; - } - } - } - - private final CompilerToVM compilerToVM; - - public void removeStaleGraphs() { - long[] deoptedGraphs = compilerToVM.getDeoptedLeafGraphIds(); - if (deoptedGraphs != null) { - if (deoptedGraphs.length == 0) { - clear(); - } else { - removeGraphs(deoptedGraphs); - } - } - } -} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotLoweringProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -700,9 +700,9 @@ public int getScalingFactor(Kind kind) { if (useCompressedOops() && kind == Kind.Object) { - return this.runtime.getTarget().arch.getSizeInBytes(Kind.Int); + return this.runtime.getTarget().getSizeInBytes(Kind.Int); } else { - return this.runtime.getTarget().arch.getSizeInBytes(kind); + return this.runtime.getTarget().getSizeInBytes(kind); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMetaAccessProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -120,8 +120,7 @@ HotSpotResolvedObjectType resolved = (HotSpotResolvedObjectType) holder; return resolved.createField(name, type, offset, modifiers); } else { - // TODO this cast will not succeed - return (ResolvedJavaField) new HotSpotUnresolvedField(holder, name, type); + throw GraalInternalError.shouldNotReachHere("unresolved field " + reflectionField); } } @@ -300,7 +299,7 @@ ResolvedJavaType elementType = lookupJavaType.getComponentType(); Kind elementKind = elementType.getKind(); final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind); - int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().arch.getSizeInBytes(elementKind); + int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind); int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize; int log2ElementSize = CodeUtil.log2(sizeOfElement); return NewObjectSnippets.computeArrayAllocationSize(length, alignment, headerSize, log2ElementSize); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Mon Mar 17 14:30:59 2014 +0100 @@ -825,4 +825,12 @@ super(runtime().getConfig().dataLayoutArgInfoDataTag, ARG_INFO_DATA_SIZE); } } + + public void setCompiledGraphSize(int nodeCount) { + unsafe.putInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset, nodeCount); + } + + public int getCompiledGraphSize() { + return unsafe.getInt(metaspaceMethodData + config.methodDataGraalNodeCountOffset); + } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotNmethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -43,7 +43,12 @@ private static final long serialVersionUID = -1784683588947054103L; + /** + * This (indirect) Method* reference is safe since class redefinition preserves all methods + * associated with nmethods in the code cache. + */ private final HotSpotResolvedJavaMethod method; + private final boolean isDefault; private final boolean isExternal; private final String name; @@ -84,7 +89,7 @@ @Override public String toString() { - return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=]", method, getCodeBlob(), isDefault, name); + return String.format("InstalledNmethod[method=%s, codeBlob=0x%x, isDefault=%b, name=%s]", method, getCodeBlob(), isDefault, name); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.java Mon Mar 17 14:30:59 2014 +0100 @@ -25,6 +25,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; +import com.oracle.graal.nodes.*; public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo { @@ -205,4 +206,21 @@ public void setMature() { isMature = true; } + + @Override + public boolean setCompilerIRSize(Class irType, int size) { + if (irType == StructuredGraph.class) { + methodData.setCompiledGraphSize(size); + return true; + } + return false; + } + + @Override + public int getCompilerIRSize(Class irType) { + if (irType == StructuredGraph.class) { + return methodData.getCompiledGraphSize(); + } + return -1; + } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Mon Mar 17 14:30:59 2014 +0100 @@ -51,13 +51,8 @@ private final String name; private JavaType type; private final int offset; - private Constant constant; /** - * The {@linkplain HotSpotResolvedObjectType#getReflectionFieldModifiers() reflection} modifiers - * for this field plus the {@link #FIELD_INTERNAL_FLAG} if it applies. - */ - /** * This value contains all flags as stored in the VM including internal ones. */ private final int modifiers; @@ -73,6 +68,23 @@ } @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof HotSpotResolvedJavaField) { + HotSpotResolvedJavaField that = (HotSpotResolvedJavaField) obj; + return this.holder.equals(that.holder) && this.name.equals(that.name) && this.type.equals(that.type); + } + return false; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override public int getModifiers() { return modifiers & getReflectionFieldModifiers(); } @@ -189,14 +201,12 @@ if (receiver == null) { assert isStatic(modifiers); - if (constant == null) { + if (Modifier.isFinal(getModifiers())) { if (holder.isInitialized() && !holder.getName().equals(SystemClassName) && isEmbeddable()) { - if (Modifier.isFinal(getModifiers())) { - constant = readValue(receiver); - } + return readValue(receiver); + } } - return constant; } else { /* * for non-static final fields, we must assume that they are only initialized if they diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -28,8 +28,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -59,10 +57,8 @@ private boolean forceInline; private boolean dontInline; private boolean ignoredBySecurityStackWalk; - private Map compilerStorage; private HotSpotMethodData methodData; private byte[] code; - private CompilationTask currentTask; private SpeculationLog speculationLog; /** @@ -128,6 +124,20 @@ return unsafe.getAddress(metaspaceMethod + runtime().getConfig().methodConstMethodOffset); } + @Override + public boolean equals(Object obj) { + if (obj instanceof HotSpotResolvedJavaMethod) { + HotSpotResolvedJavaMethod that = (HotSpotResolvedJavaMethod) obj; + return that.metaspaceMethod == metaspaceMethod; + } + return false; + } + + @Override + public int hashCode() { + return (int) metaspaceMethod; + } + /** * Returns this method's constant method flags ({@code ConstMethod::_flags}). * @@ -343,10 +353,6 @@ return signature; } - public int getCompiledCodeSize() { - return runtime().getCompilerToVM().getCompiledCodeSize(metaspaceMethod); - } - /** * Gets the value of {@code Method::_code}. * @@ -420,14 +426,6 @@ } @Override - public Map getCompilerStorage() { - if (compilerStorage == null) { - compilerStorage = new ConcurrentHashMap<>(); - } - return compilerStorage; - } - - @Override public ConstantPool getConstantPool() { return constantPool; } @@ -600,14 +598,6 @@ return unsafe.getInt(metaspaceMethod + config.methodVtableIndexOffset); } - public void setCurrentTask(CompilationTask task) { - currentTask = task; - } - - public CompilationTask currentTask() { - return currentTask; - } - public SpeculationLog getSpeculationLog() { if (speculationLog == null) { speculationLog = new SpeculationLog(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Mon Mar 17 14:30:59 2014 +0100 @@ -44,4 +44,19 @@ } public abstract Class mirror(); + + @Override + public final boolean equals(Object obj) { + if (!(obj instanceof HotSpotResolvedJavaType)) { + return false; + } + HotSpotResolvedJavaType that = (HotSpotResolvedJavaType) obj; + return this.mirror().equals(that.mirror()); + } + + @Override + public final int hashCode() { + return getName().hashCode(); + } + } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Mon Mar 17 14:30:59 2014 +0100 @@ -593,7 +593,7 @@ } if (!includeSuperclasses) { int myFieldsStart = 0; - while (myFieldsStart < instanceFields.length && instanceFields[myFieldsStart].getDeclaringClass() != this) { + while (myFieldsStart < instanceFields.length && !instanceFields[myFieldsStart].getDeclaringClass().equals(this)) { myFieldsStart++; } if (myFieldsStart == 0) { @@ -763,20 +763,6 @@ } @Override - public boolean equals(Object obj) { - if (!(obj instanceof HotSpotResolvedObjectType)) { - return false; - } - HotSpotResolvedObjectType that = (HotSpotResolvedObjectType) obj; - return this.mirror() == that.mirror(); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override public String toString() { String simpleName; if (isArray() || isInterface()) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Mon Mar 17 14:30:59 2014 +0100 @@ -70,7 +70,10 @@ @Override public ResolvedJavaType getArrayClass() { - Class javaArrayMirror = kind == Kind.Void ? null : Array.newInstance(mirror(), 0).getClass(); + if (kind == Kind.Void) { + return null; + } + Class javaArrayMirror = Array.newInstance(mirror(), 0).getClass(); return HotSpotResolvedObjectType.fromClass(javaArrayMirror); } @@ -151,7 +154,7 @@ @Override public boolean isAssignableFrom(ResolvedJavaType other) { assert other != null; - return other == this; + return other.equals(this); } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Mon Mar 17 14:30:59 2014 +0100 @@ -157,8 +157,8 @@ Suites suites = providers.getSuites().createSuites(); PhaseSuite phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy(); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, g.method(), false); - CompilationResult compResult = GraalCompiler.compileGraph(g, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL, - DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, true, new CompilationResult(), CompilationResultBuilderFactory.Default); + CompilationResult compResult = GraalCompiler.compileGraph(g, null, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL, + DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, new CompilationResult(), CompilationResultBuilderFactory.Default); InstalledCode installedCode; try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) { installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes.type; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public class NarrowOopStamp extends ObjectStamp { + + public static final PlatformKind NarrowOop = new PlatformKind() { + + public String name() { + return "NarrowOop"; + } + + @Override + public String toString() { + return name(); + } + }; + + private final CompressEncoding encoding; + + public NarrowOopStamp(ObjectStamp stamp, CompressEncoding encoding) { + this(stamp.type(), stamp.isExactType(), stamp.nonNull(), stamp.alwaysNull(), encoding); + } + + public NarrowOopStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull, CompressEncoding encoding) { + super(type, exactType, nonNull, alwaysNull); + this.encoding = encoding; + } + + public Stamp uncompressed() { + return new ObjectStamp(type(), isExactType(), nonNull(), alwaysNull()); + } + + public CompressEncoding getEncoding() { + return encoding; + } + + @Override + public Stamp unrestricted() { + return new NarrowOopStamp((ObjectStamp) super.unrestricted(), encoding); + } + + @Override + public Kind getStackKind() { + return Kind.Object; + } + + @Override + public PlatformKind getPlatformKind(LIRTypeTool tool) { + return NarrowOop; + } + + @Override + public String toString() { + StringBuilder str = new StringBuilder(); + str.append('n'); + str.append(super.toString()); + return str.toString(); + } + + @Override + public Stamp meet(Stamp otherStamp) { + if (this == otherStamp) { + return this; + } + if (otherStamp instanceof IllegalStamp) { + return otherStamp.meet(this); + } + if (!isCompatible(otherStamp)) { + return StampFactory.illegal(Kind.Illegal); + } + return new NarrowOopStamp((ObjectStamp) super.meet(otherStamp), encoding); + } + + @Override + public Stamp join(Stamp otherStamp) { + if (this == otherStamp) { + return this; + } + if (otherStamp instanceof IllegalStamp) { + return otherStamp.join(this); + } + if (!isCompatible(otherStamp)) { + return StampFactory.illegal(Kind.Illegal); + } + return new NarrowOopStamp((ObjectStamp) super.join(otherStamp), encoding); + } + + @Override + public boolean isCompatible(Stamp other) { + if (this == other) { + return true; + } + if (other instanceof NarrowOopStamp) { + NarrowOopStamp narrow = (NarrowOopStamp) other; + return encoding.equals(narrow.encoding); + } + return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + encoding.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + NarrowOopStamp other = (NarrowOopStamp) obj; + if (!encoding.equals(other.encoding)) { + return false; + } + return super.equals(other); + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/AheadOfTimeVerificationPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -42,7 +42,9 @@ protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ConstantNode node : getConstantNodes(graph)) { if (node.recordsUsages() || !node.gatherUsages(graph).isEmpty()) { - assert !isObject(node) || isNullReference(node) || isInternedString(node) : "illegal object constant: " + node; + if (isObject(node) && !isNullReference(node) && !isInternedString(node)) { + throw new VerificationError("illegal object constant: " + node); + } } } return true; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/OnStackReplacementPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -30,7 +30,6 @@ import com.oracle.graal.loop.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; @@ -94,13 +93,15 @@ for (int i = 0; i < osrState.localsSize(); i++) { ValueNode value = osrState.localAt(i); - if (value != null) { + if (value instanceof ProxyNode) { ProxyNode proxy = (ProxyNode) value; /* - * we need to drop the stamp and go back to the kind since the types we see during - * OSR may be too precise (if a branch was not parsed for example). + * we need to drop the stamp since the types we see during OSR may be too precise + * (if a branch was not parsed for example). */ - proxy.replaceAndDelete(graph.unique(new OSRLocalNode(i, StampFactory.forKind(proxy.kind())))); + proxy.replaceAndDelete(graph.unique(new OSRLocalNode(i, proxy.stamp().unrestricted()))); + } else { + assert value == null || value instanceof OSRLocalNode; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -73,11 +73,11 @@ Node currentNode = iterator.next(); assert !isSafepoint(currentNode) : "Write barrier must be present " + write; if (useG1GC()) { - if (!(currentNode instanceof G1PostWriteBarrier) || ((currentNode instanceof G1PostWriteBarrier) && !validateBarrier((FixedAccessNode) write, (WriteBarrier) currentNode))) { + if (!(currentNode instanceof G1PostWriteBarrier) || (!validateBarrier((FixedAccessNode) write, (WriteBarrier) currentNode))) { expandFrontier(frontier, currentNode); } } else { - if (!(currentNode instanceof SerialWriteBarrier) || ((currentNode instanceof SerialWriteBarrier) && !validateBarrier((FixedAccessNode) write, (WriteBarrier) currentNode)) || + if (!(currentNode instanceof SerialWriteBarrier) || (!validateBarrier((FixedAccessNode) write, (WriteBarrier) currentNode)) || ((currentNode instanceof SerialWriteBarrier) && !validateBarrier((FixedAccessNode) write, (WriteBarrier) currentNode))) { expandFrontier(frontier, currentNode); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Mon Mar 17 14:30:59 2014 +0100 @@ -46,6 +46,9 @@ */ public class HotSpotReplacementsUtil { + // Must be @Fold as the security checks in HotSpotGraalRuntime.runtime() + // don't work well inside snippets + @Fold public static HotSpotVMConfig config() { return runtime().getConfig(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ThreadSubstitutions.java Mon Mar 17 14:30:59 2014 +0100 @@ -45,7 +45,7 @@ @MethodSubstitution public static Thread currentThread() { - return PiNode.piCastExactNonNull(CurrentJavaThreadNode.get().readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION), Thread.class); + return PiNode.piCastNonNull(CurrentJavaThreadNode.get().readObject(threadObjectOffset(), LocationIdentity.FINAL_LOCATION), Thread.class); } @MethodSubstitution(isStatic = false) diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Mon Mar 17 14:30:59 2014 +0100 @@ -186,7 +186,6 @@ boolean isObjectResult = linkage.getOutgoingCallingConvention().getReturn().getKind() == Kind.Object; StructuredGraph graph = new StructuredGraph(toString(), null); - graph.replaceFixed(graph.start(), graph.add(new StubStartNode(this))); GraphKit kit = new GraphKit(graph, providers); ParameterNode[] params = createParameters(kit, args); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Mon Mar 17 14:30:59 2014 +0100 @@ -145,15 +145,15 @@ CodeCacheProvider codeCache = providers.getCodeCache(); // The stub itself needs the incoming calling convention. CallingConvention incomingCc = linkage.getIncomingCallingConvention(); - final CompilationResult compResult = compileGraph(graph, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, - providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(), true, + final CompilationResult compResult = compileGraph(graph, Stub.this, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, + providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, providers.getSuites().getDefaultSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); assert destroyedRegisters != null; try (Scope s = Debug.scope("CodeInstall")) { Stub stub = Stub.this; HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub); - HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(backend.getTarget().arch, stub, compResult); + HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(backend.getTarget(), stub, compResult); CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null); if (result != CodeInstallResult.OK) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java --- a/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAIL.java Mon Mar 17 14:30:59 2014 +0100 @@ -168,7 +168,7 @@ Kind kind = arg.getKind(); if (kind == Kind.Double || kind == Kind.Long) { regPrefix = "$d"; - } else if (kind == Kind.Int || kind == Kind.Float || kind == Kind.NarrowOop) { + } else if (kind == Kind.Int || kind == Kind.Float) { regPrefix = "$s"; } else { regPrefix = "$d"; @@ -193,7 +193,6 @@ case Int: case Long: case Object: - case NarrowOop: return true; } } else if (category == FPU) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAILRegisterConfig.java --- a/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAILRegisterConfig.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.hsail/src/com/oracle/graal/hsail/HSAILRegisterConfig.java Mon Mar 17 14:30:59 2014 +0100 @@ -123,7 +123,7 @@ if (locations[i] == null) { locations[i] = StackSlot.get(kind.getStackKind(), currentStackOffset, !type.out); - currentStackOffset += Math.max(target.arch.getSizeInBytes(kind), target.wordSize); + currentStackOffset += Math.max(target.getSizeInBytes(kind), target.wordSize); } } @@ -150,7 +150,6 @@ case Short: case Byte: case Float: - case NarrowOop: return regBitness32.clone(); case Long: case Double: diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/DecompilerTest.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.java.decompiler.test; + +import java.lang.reflect.*; + +import org.junit.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.java.decompiler.test.example.*; +import com.oracle.graal.printer.*; +import com.oracle.graal.runtime.*; + +@Ignore +public class DecompilerTest { + + public static void doTest(String name) { + try { + DebugEnvironment.initialize(System.out); + MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); + Method method = Example.class.getDeclaredMethod(name, new Class[]{int.class, int.class}); + final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); + TestUtil.compileMethod(javaMethod); + } catch (NoSuchMethodException e) { + Assert.fail(); + } catch (SecurityException e) { + Assert.fail(); + } + } + + @Test + public void test01() { + doTest("loop7"); + } + + @Test + public void test02() { + doTest("loop6"); + } + + @Test + public void test03() { + doTest("loop5"); + } + + @Test + public void test04() { + doTest("loop4"); + } + + @Test + public void test05() { + doTest("loop3"); + } + + @Test + public void test06() { + doTest("loop2"); + } + + @Test + public void test07() { + doTest("loop"); + } + + @Test + public void test08() { + doTest("if0"); + } + + @Test + public void test09() { + doTest("if1"); + } + + @Test + public void test10() { + doTest("if2"); + } + + @Test + public void test11() { + doTest("if3"); + } + + @Test + public void test12() { + doTest("if4"); + } +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/Test.java Mon Mar 17 14:29:45 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.java.decompiler.test; - -import java.lang.reflect.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.java.decompiler.test.example.*; -import com.oracle.graal.printer.*; -import com.oracle.graal.runtime.*; - -public class Test { - - /** - * @param args - * @throws SecurityException - * @throws NoSuchMethodException - */ - public static void main(String[] args) throws NoSuchMethodException, SecurityException { - DebugEnvironment.initialize(System.out); - MetaAccessProvider metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); - Method method = Example.class.getDeclaredMethod("loop7", new Class[]{int.class, int.class}); - final ResolvedJavaMethod javaMethod = metaAccess.lookupJavaMethod(method); - TestUtil.compileMethod(javaMethod); - } -} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java --- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,6 +24,7 @@ import static com.oracle.graal.api.code.CodeUtil.*; import static com.oracle.graal.compiler.GraalCompiler.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; @@ -49,7 +50,7 @@ new GraphBuilderPhase.Instance(metaAccess, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); PhaseSuite graphBuilderSuite = suitesProvider.getDefaultGraphBuilderSuite(); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); - compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites, true, + compileGraph(graph, null, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites, new CompilationResult(), CompilationResultBuilderFactory.Default); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/Decompiler.java --- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/Decompiler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/Decompiler.java Mon Mar 17 14:30:59 2014 +0100 @@ -25,6 +25,7 @@ import java.io.*; import java.util.*; +import com.oracle.graal.graph.*; import com.oracle.graal.java.decompiler.block.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; @@ -55,9 +56,9 @@ schedule = new SchedulePhase(); schedule.apply(graph); } catch (Throwable t) { + throw new GraalInternalError(t); } } - cfg = schedule.getCFG(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java --- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/DecompilerIfSimplify.java Mon Mar 17 14:30:59 2014 +0100 @@ -68,7 +68,7 @@ // TODO(mg) // thenBlocks and elseBlocks can be both empty --> causes an AssertionError DecompilerIfBlock ifBlock = new DecompilerIfBlock(block.getBlock(), decompiler, thenBlocks, elseBlocks, infoStream); - if (thenBlocks.contains(block.getBlock()) || elseBlocks.contains(block.getBlock())) { + if (thenBlocks.contains(block) || elseBlocks.contains(block)) { throw new AssertionError(); } blocks.add(ifBlock); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java --- a/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java.decompiler/src/com/oracle/graal/java/decompiler/block/DecompilerIfBlock.java Mon Mar 17 14:30:59 2014 +0100 @@ -158,7 +158,20 @@ @Override public boolean contains(Block b) { - return b == block || thenBranch.contains(b) || elseBranch.contains(b); + if (b == block) { + return true; + } + for (DecompilerBlock i : thenBranch) { + if (i.block == b) { + return true; + } + } + for (DecompilerBlock i : elseBranch) { + if (i.block == b) { + return true; + } + } + return false; } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BciBlockMapping.java Mon Mar 17 14:30:59 2014 +0100 @@ -99,11 +99,6 @@ public Block retSuccessor; public boolean endsWithRet = false; - public BitSet localsLiveIn; - public BitSet localsLiveOut; - private BitSet localsLiveGen; - private BitSet localsLiveKill; - public Block exceptionDispatchBlock() { if (successors.size() > 0 && successors.get(successors.size() - 1) instanceof ExceptionDispatchBlock) { return successors.get(successors.size() - 1); @@ -167,6 +162,8 @@ private Block[] blockMap; public Block[] loopHeaders; + public LocalLiveness liveness; + /** * Creates a new BlockMap instance from bytecode of the given method . * @@ -212,7 +209,8 @@ } if (OptLivenessAnalysis.getValue()) { try (Scope s = Debug.scope("LivenessAnalysis")) { - computeLiveness(); + liveness = method.getMaxLocals() <= 64 ? new SmallLocalLiveness() : new LargeLocalLiveness(); + liveness.computeLiveness(); } catch (Throwable e) { throw Debug.handle(e); } @@ -729,153 +727,225 @@ return loops; } - private void computeLiveness() { - for (Block block : blocks) { - computeLocalLiveness(block); - } + /** + * Encapsulates the liveness calculation, so that subclasses for locals <= 64 and locals > 64 + * can be implemented. + */ + public abstract class LocalLiveness { + + private void computeLiveness() { + for (Block block : blocks) { + computeLocalLiveness(block); + } - boolean changed; - int iteration = 0; - do { - Debug.log("Iteration %d", iteration); - changed = false; - for (int i = blocks.size() - 1; i >= 0; i--) { - Block block = blocks.get(i); - Debug.log(" start B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, block.localsLiveIn, block.localsLiveOut, block.localsLiveGen, - block.localsLiveKill); + boolean changed; + int iteration = 0; + do { + Debug.log("Iteration %d", iteration); + changed = false; + for (int i = blocks.size() - 1; i >= 0; i--) { + Block block = blocks.get(i); + int blockID = block.blockID; + // log statements in IFs because debugLiveX creates a new String + if (Debug.isLogEnabled()) { + Debug.log(" start B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), + debugLiveGen(blockID), debugLiveKill(blockID)); + } - boolean blockChanged = (iteration == 0); - if (block.successors.size() > 0) { - int oldCardinality = block.localsLiveOut.cardinality(); - for (Block sux : block.successors) { - Debug.log(" Successor B%d: %s", sux.blockID, sux.localsLiveIn); - block.localsLiveOut.or(sux.localsLiveIn); + boolean blockChanged = (iteration == 0); + if (block.successors.size() > 0) { + int oldCardinality = liveOutCardinality(blockID); + for (Block sux : block.successors) { + if (Debug.isLogEnabled()) { + Debug.log(" Successor B%d: %s", sux.blockID, debugLiveIn(sux.blockID)); + } + propagateLiveness(blockID, sux.blockID); + } + blockChanged |= (oldCardinality != liveOutCardinality(blockID)); } - blockChanged |= (oldCardinality != block.localsLiveOut.cardinality()); + + if (blockChanged) { + updateLiveness(blockID); + if (Debug.isLogEnabled()) { + Debug.log(" end B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, debugLiveIn(blockID), debugLiveOut(blockID), + debugLiveGen(blockID), debugLiveKill(blockID)); + } + } + changed |= blockChanged; } - - if (blockChanged) { - block.localsLiveIn.clear(); - block.localsLiveIn.or(block.localsLiveOut); - block.localsLiveIn.andNot(block.localsLiveKill); - block.localsLiveIn.or(block.localsLiveGen); - Debug.log(" end B%d [%d, %d] in: %s out: %s gen: %s kill: %s", block.blockID, block.startBci, block.endBci, block.localsLiveIn, block.localsLiveOut, block.localsLiveGen, - block.localsLiveKill); - } - changed |= blockChanged; - } - iteration++; - } while (changed); - } - - private void computeLocalLiveness(Block block) { - block.localsLiveIn = new BitSet(method.getMaxLocals()); - block.localsLiveOut = new BitSet(method.getMaxLocals()); - block.localsLiveGen = new BitSet(method.getMaxLocals()); - block.localsLiveKill = new BitSet(method.getMaxLocals()); - - if (block.startBci < 0 || block.endBci < 0) { - return; + iteration++; + } while (changed); } - stream.setBCI(block.startBci); - while (stream.currentBCI() <= block.endBci) { - switch (stream.currentBC()) { - case LLOAD: - case DLOAD: - loadTwo(block, stream.readLocalIndex()); - break; - case LLOAD_0: - case DLOAD_0: - loadTwo(block, 0); - break; - case LLOAD_1: - case DLOAD_1: - loadTwo(block, 1); - break; - case LLOAD_2: - case DLOAD_2: - loadTwo(block, 2); - break; - case LLOAD_3: - case DLOAD_3: - loadTwo(block, 3); - break; - case ILOAD: - case IINC: - case FLOAD: - case ALOAD: - case RET: - loadOne(block, stream.readLocalIndex()); - break; - case ILOAD_0: - case FLOAD_0: - case ALOAD_0: - loadOne(block, 0); - break; - case ILOAD_1: - case FLOAD_1: - case ALOAD_1: - loadOne(block, 1); - break; - case ILOAD_2: - case FLOAD_2: - case ALOAD_2: - loadOne(block, 2); - break; - case ILOAD_3: - case FLOAD_3: - case ALOAD_3: - loadOne(block, 3); - break; + /** + * Returns whether the local is live at the beginning of the given block. + */ + public abstract boolean localIsLiveIn(Block block, int local); + + /** + * Returns whether the local is live at the end of the given block. + */ + public abstract boolean localIsLiveOut(Block block, int local); + + /** + * Returns a string representation of the liveIn values of the given block. + */ + protected abstract String debugLiveIn(int blockID); + + /** + * Returns a string representation of the liveOut values of the given block. + */ + protected abstract String debugLiveOut(int blockID); + + /** + * Returns a string representation of the liveGen values of the given block. + */ + protected abstract String debugLiveGen(int blockID); + + /** + * Returns a string representation of the liveKill values of the given block. + */ + protected abstract String debugLiveKill(int blockID); + + /** + * Returns the number of live locals at the end of the given block. + */ + protected abstract int liveOutCardinality(int blockID); + + /** + * Adds all locals the are in the liveIn of the successor to the liveOut of the block. + */ + protected abstract void propagateLiveness(int blockID, int successorID); + + /** + * Calculates a new liveIn for the given block from liveOut, liveKill and liveGen. + */ + protected abstract void updateLiveness(int blockID); + + /** + * Adds the local to liveGen if it wasn't already killed in this block. + */ + protected abstract void loadOne(int blockID, int local); + + /** + * Add this local to liveKill if it wasn't already generated in this block. + */ + protected abstract void storeOne(int blockID, int local); - case LSTORE: - case DSTORE: - storeTwo(block, stream.readLocalIndex()); - break; - case LSTORE_0: - case DSTORE_0: - storeTwo(block, 0); - break; - case LSTORE_1: - case DSTORE_1: - storeTwo(block, 1); - break; - case LSTORE_2: - case DSTORE_2: - storeTwo(block, 2); - break; - case LSTORE_3: - case DSTORE_3: - storeTwo(block, 3); - break; - case ISTORE: - case FSTORE: - case ASTORE: - storeOne(block, stream.readLocalIndex()); - break; - case ISTORE_0: - case FSTORE_0: - case ASTORE_0: - storeOne(block, 0); - break; - case ISTORE_1: - case FSTORE_1: - case ASTORE_1: - storeOne(block, 1); - break; - case ISTORE_2: - case FSTORE_2: - case ASTORE_2: - storeOne(block, 2); - break; - case ISTORE_3: - case FSTORE_3: - case ASTORE_3: - storeOne(block, 3); - break; + private void computeLocalLiveness(Block block) { + if (block.startBci < 0 || block.endBci < 0) { + return; } - stream.next(); + int blockID = block.blockID; + stream.setBCI(block.startBci); + while (stream.currentBCI() <= block.endBci) { + switch (stream.currentBC()) { + case LLOAD: + case DLOAD: + loadTwo(blockID, stream.readLocalIndex()); + break; + case LLOAD_0: + case DLOAD_0: + loadTwo(blockID, 0); + break; + case LLOAD_1: + case DLOAD_1: + loadTwo(blockID, 1); + break; + case LLOAD_2: + case DLOAD_2: + loadTwo(blockID, 2); + break; + case LLOAD_3: + case DLOAD_3: + loadTwo(blockID, 3); + break; + case ILOAD: + case IINC: + case FLOAD: + case ALOAD: + case RET: + loadOne(blockID, stream.readLocalIndex()); + break; + case ILOAD_0: + case FLOAD_0: + case ALOAD_0: + loadOne(blockID, 0); + break; + case ILOAD_1: + case FLOAD_1: + case ALOAD_1: + loadOne(blockID, 1); + break; + case ILOAD_2: + case FLOAD_2: + case ALOAD_2: + loadOne(blockID, 2); + break; + case ILOAD_3: + case FLOAD_3: + case ALOAD_3: + loadOne(blockID, 3); + break; + + case LSTORE: + case DSTORE: + storeTwo(blockID, stream.readLocalIndex()); + break; + case LSTORE_0: + case DSTORE_0: + storeTwo(blockID, 0); + break; + case LSTORE_1: + case DSTORE_1: + storeTwo(blockID, 1); + break; + case LSTORE_2: + case DSTORE_2: + storeTwo(blockID, 2); + break; + case LSTORE_3: + case DSTORE_3: + storeTwo(blockID, 3); + break; + case ISTORE: + case FSTORE: + case ASTORE: + storeOne(blockID, stream.readLocalIndex()); + break; + case ISTORE_0: + case FSTORE_0: + case ASTORE_0: + storeOne(blockID, 0); + break; + case ISTORE_1: + case FSTORE_1: + case ASTORE_1: + storeOne(blockID, 1); + break; + case ISTORE_2: + case FSTORE_2: + case ASTORE_2: + storeOne(blockID, 2); + break; + case ISTORE_3: + case FSTORE_3: + case ASTORE_3: + storeOne(blockID, 3); + break; + } + stream.next(); + } + } + + private void loadTwo(int blockID, int local) { + loadOne(blockID, local); + loadOne(blockID, local + 1); + } + + private void storeTwo(int blockID, int local) { + storeOne(blockID, local); + storeOne(blockID, local + 1); } } @@ -889,25 +959,182 @@ return map; } - private static void loadTwo(Block block, int local) { - loadOne(block, local); - loadOne(block, local + 1); - } + public final class SmallLocalLiveness extends LocalLiveness { + /* + * local n is represented by the bit accessible as (1 << n) + */ + + private final long[] localsLiveIn; + private final long[] localsLiveOut; + private final long[] localsLiveGen; + private final long[] localsLiveKill; + + public SmallLocalLiveness() { + localsLiveIn = new long[blocks.size()]; + localsLiveOut = new long[blocks.size()]; + localsLiveGen = new long[blocks.size()]; + localsLiveKill = new long[blocks.size()]; + } + + private String debugString(long value) { + StringBuilder str = new StringBuilder("{"); + long current = value; + for (int i = 0; i < method.getMaxLocals(); i++) { + if ((current & 1L) == 1L) { + if (str.length() > 1) { + str.append(", "); + } + str.append(i); + } + current >>= 1; + } + return str.append('}').toString(); + } + + @Override + protected String debugLiveIn(int blockID) { + return debugString(localsLiveIn[blockID]); + } + + @Override + protected String debugLiveOut(int blockID) { + return debugString(localsLiveOut[blockID]); + } + + @Override + protected String debugLiveGen(int blockID) { + return debugString(localsLiveGen[blockID]); + } - private static void loadOne(Block block, int local) { - if (!block.localsLiveKill.get(local)) { - block.localsLiveGen.set(local); + @Override + protected String debugLiveKill(int blockID) { + return debugString(localsLiveKill[blockID]); + } + + @Override + protected int liveOutCardinality(int blockID) { + return Long.bitCount(localsLiveOut[blockID]); + } + + @Override + protected void propagateLiveness(int blockID, int successorID) { + localsLiveOut[blockID] |= localsLiveIn[successorID]; + } + + @Override + protected void updateLiveness(int blockID) { + localsLiveIn[blockID] = (localsLiveOut[blockID] & ~localsLiveKill[blockID]) | localsLiveGen[blockID]; + } + + @Override + protected void loadOne(int blockID, int local) { + long bit = 1L << local; + if ((localsLiveKill[blockID] & bit) == 0L) { + localsLiveGen[blockID] |= bit; + } + } + + @Override + protected void storeOne(int blockID, int local) { + long bit = 1L << local; + if ((localsLiveGen[blockID] & bit) == 0L) { + localsLiveKill[blockID] |= bit; + } + } + + @Override + public boolean localIsLiveIn(Block block, int local) { + int blockID = block.blockID; + return blockID >= Integer.MAX_VALUE ? false : (localsLiveIn[blockID] & (1L << local)) != 0L; + } + + @Override + public boolean localIsLiveOut(Block block, int local) { + int blockID = block.blockID; + return blockID >= Integer.MAX_VALUE ? false : (localsLiveOut[blockID] & (1L << local)) != 0L; } } - private static void storeTwo(Block block, int local) { - storeOne(block, local); - storeOne(block, local + 1); - } + public final class LargeLocalLiveness extends LocalLiveness { + private BitSet[] localsLiveIn; + private BitSet[] localsLiveOut; + private BitSet[] localsLiveGen; + private BitSet[] localsLiveKill; + + public LargeLocalLiveness() { + localsLiveIn = new BitSet[blocks.size()]; + localsLiveOut = new BitSet[blocks.size()]; + localsLiveGen = new BitSet[blocks.size()]; + localsLiveKill = new BitSet[blocks.size()]; + for (int i = 0; i < blocks.size(); i++) { + localsLiveIn[i] = new BitSet(method.getMaxLocals()); + localsLiveOut[i] = new BitSet(method.getMaxLocals()); + localsLiveGen[i] = new BitSet(method.getMaxLocals()); + localsLiveKill[i] = new BitSet(method.getMaxLocals()); + } + } + + @Override + protected String debugLiveIn(int blockID) { + return localsLiveIn[blockID].toString(); + } + + @Override + protected String debugLiveOut(int blockID) { + return localsLiveOut[blockID].toString(); + } + + @Override + protected String debugLiveGen(int blockID) { + return localsLiveGen[blockID].toString(); + } + + @Override + protected String debugLiveKill(int blockID) { + return localsLiveKill[blockID].toString(); + } - private static void storeOne(Block block, int local) { - if (!block.localsLiveGen.get(local)) { - block.localsLiveKill.set(local); + @Override + protected int liveOutCardinality(int blockID) { + return localsLiveOut[blockID].cardinality(); + } + + @Override + protected void propagateLiveness(int blockID, int successorID) { + localsLiveOut[blockID].or(localsLiveIn[successorID]); + } + + @Override + protected void updateLiveness(int blockID) { + BitSet liveIn = localsLiveIn[blockID]; + liveIn.clear(); + liveIn.or(localsLiveOut[blockID]); + liveIn.andNot(localsLiveKill[blockID]); + liveIn.or(localsLiveGen[blockID]); + } + + @Override + protected void loadOne(int blockID, int local) { + if (!localsLiveKill[blockID].get(local)) { + localsLiveGen[blockID].set(local); + } + } + + @Override + protected void storeOne(int blockID, int local) { + if (!localsLiveGen[blockID].get(local)) { + localsLiveKill[blockID].set(local); + } + } + + @Override + public boolean localIsLiveIn(Block block, int local) { + return block.blockID >= Integer.MAX_VALUE ? true : localsLiveIn[block.blockID].get(local); + } + + @Override + public boolean localIsLiveOut(Block block, int local) { + return block.blockID >= Integer.MAX_VALUE ? true : localsLiveOut[block.blockID].get(local); } } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeDisassembler.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeDisassembler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/BytecodeDisassembler.java Mon Mar 17 14:30:59 2014 +0100 @@ -141,7 +141,7 @@ desc = constant.toString(); } if (!multiline) { - desc.replaceAll("\\n", ""); + desc = desc.replaceAll("\\n", ""); } buf.append(String.format("#%-10d // %s", cpi, desc)); break; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/FrameStateBuilder.java Mon Mar 17 14:30:59 2014 +0100 @@ -32,6 +32,8 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.Node.Verbosity; +import com.oracle.graal.java.BciBlockMapping.Block; +import com.oracle.graal.java.BciBlockMapping.LocalLiveness; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.java.*; @@ -146,7 +148,7 @@ } public boolean isCompatibleWith(FrameStateBuilder other) { - assert method == other.method && graph == other.graph && localsSize() == other.localsSize() : "Can only compare frame states of the same method"; + assert method.equals(other.method) && graph == other.graph && localsSize() == other.localsSize() : "Can only compare frame states of the same method"; assert lockedObjects.length == monitorIds.length && other.lockedObjects.length == other.monitorIds.length : "mismatch between lockedObjects and monitorIds"; if (stackSize() != other.stackSize()) { @@ -203,7 +205,7 @@ return null; } - PhiNode phi = graph.addWithoutUnique(new PhiNode(currentValue.kind(), block)); + PhiNode phi = graph.addWithoutUnique(new PhiNode(currentValue.stamp().unrestricted(), block)); for (int i = 0; i < block.phiPredecessorCount(); i++) { phi.addInput(currentValue); } @@ -301,7 +303,7 @@ } assert !block.isPhiAtMerge(value) : "phi function for this block already created"; - PhiNode phi = graph.addWithoutUnique(new PhiNode(value.kind(), block)); + PhiNode phi = graph.addWithoutUnique(new PhiNode(value.stamp().unrestricted(), block)); phi.addInput(value); return phi; } @@ -315,13 +317,21 @@ } } - public void clearNonLiveLocals(BitSet liveness) { + public void clearNonLiveLocals(Block block, LocalLiveness liveness, boolean liveIn) { if (liveness == null) { return; } - for (int i = 0; i < locals.length; i++) { - if (!liveness.get(i)) { - locals[i] = null; + if (liveIn) { + for (int i = 0; i < locals.length; i++) { + if (!liveness.localIsLiveIn(block, i)) { + locals[i] = null; + } + } + } else { + for (int i = 0; i < locals.length; i++) { + if (!liveness.localIsLiveOut(block, i)) { + locals[i] = null; + } } } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -42,6 +42,7 @@ import com.oracle.graal.graph.*; import com.oracle.graal.java.BciBlockMapping.Block; import com.oracle.graal.java.BciBlockMapping.ExceptionDispatchBlock; +import com.oracle.graal.java.BciBlockMapping.LocalLiveness; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert; @@ -159,6 +160,7 @@ } private Block[] loopHeaders; + private LocalLiveness liveness; /** * Gets the current frame state being processed by this builder. @@ -225,6 +227,7 @@ // compute the block map, setup exception handlers and get the entrypoint(s) BciBlockMapping blockMap = BciBlockMapping.create(method); loopHeaders = blockMap.loopHeaders; + liveness = blockMap.liveness; lastInstr = currentGraph.start(); if (isSynchronized(method.getModifiers())) { @@ -233,7 +236,7 @@ methodSynchronizedObject = synchronizedObject(frameState, method); lastInstr = genMonitorEnter(methodSynchronizedObject); } - frameState.clearNonLiveLocals(blockMap.startBlock.localsLiveIn); + frameState.clearNonLiveLocals(blockMap.startBlock, liveness, true); ((StateSplit) lastInstr).setStateAfter(frameState.create(0)); if (graphBuilderConfig.eagerInfopointMode()) { @@ -825,7 +828,7 @@ * calls). Also, interfaces are initialized only under special circumstances, so that * this assertion would often fail for interface calls. */ - assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaMethod && (opcode != INVOKESTATIC || ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized())); + assert !graphBuilderConfig.unresolvedIsError() || (result instanceof ResolvedJavaMethod && (opcode != INVOKESTATIC || ((ResolvedJavaMethod) result).getDeclaringClass().isInitialized())) : result; return result; } @@ -839,7 +842,7 @@ private Object lookupConstant(int cpi, int opcode) { eagerResolvingForSnippets(cpi, opcode); Object result = constantPool.lookupConstant(cpi); - assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType); + assert !graphBuilderConfig.eagerResolving() || !(result instanceof JavaType) || (result instanceof ResolvedJavaType) : result; return result; } @@ -1228,7 +1231,7 @@ createInvoke(callTarget, resultType); } else { assert bci() == currentBlock.endBci; - frameState.clearNonLiveLocals(currentBlock.localsLiveOut); + frameState.clearNonLiveLocals(currentBlock, liveness, false); InvokeWithExceptionNode invoke = createInvokeWithException(callTarget, resultType); @@ -1544,7 +1547,7 @@ Target target = checkLoopExit(block.firstInstruction, block, state); FixedNode result = target.fixed; block.entryState = target.state == state ? state.copy() : target.state; - block.entryState.clearNonLiveLocals(block.localsLiveIn); + block.entryState.clearNonLiveLocals(block, liveness, true); Debug.log("createTarget %s: first visit, result: %s", block, block.firstInstruction); return result; @@ -1823,7 +1826,7 @@ bci = stream.currentBCI(); if (bci > block.endBci) { - frameState.clearNonLiveLocals(currentBlock.localsLiveOut); + frameState.clearNonLiveLocals(currentBlock, liveness, false); } if (lastInstr instanceof StateSplit) { if (lastInstr.getClass() == AbstractBeginNode.class) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/VerifyOptionsPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -100,7 +100,7 @@ } } else if (boxingTypes.contains(holder)) { return method.getName().equals("valueOf"); - } else if (method.getDeclaringClass() == metaAccess.lookupJavaType(Class.class)) { + } else if (method.getDeclaringClass().equals(metaAccess.lookupJavaType(Class.class))) { return method.getName().equals("desiredAssertionStatus"); } else if (method.getDeclaringClass().equals(declaringClass)) { return (method.getName().equals("$jacocoInit")); @@ -113,7 +113,7 @@ for (ValueNode node : graph.getNodes().filter(ValueNode.class)) { if (node instanceof StoreFieldNode) { ResolvedJavaField field = ((StoreFieldNode) node).field(); - verify(field.getDeclaringClass() == declaringClass, node, "store to field " + format("%H.%n", field)); + verify(field.getDeclaringClass().equals(declaringClass), node, "store to field " + format("%H.%n", field)); verify(isStatic(field.getModifiers()), node, "store to field " + format("%H.%n", field)); if (optionValueType.isAssignableFrom((ResolvedJavaType) field.getType())) { verify(isFinal(field.getModifiers()), node, "option field " + format("%H.%n", field) + " not final"); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64FrameMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -101,9 +101,4 @@ protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } - - @Override - public LIRInstruction createSpillMove(AllocatableValue result, Value input) { - return AMD64Move.createMove(result, input); - } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Mon Mar 17 14:30:59 2014 +0100 @@ -41,16 +41,6 @@ public class AMD64Move { - public static AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { - if (src instanceof AMD64AddressValue) { - return new LeaOp(dst, (AMD64AddressValue) src); - } else if (isRegister(src) || isStackSlot(dst)) { - return new MoveFromRegOp(dst, src); - } else { - return new MoveToRegOp(dst, src); - } - } - @Opcode("MOVE") public static class MoveToRegOp extends AMD64LIRInstruction implements MoveOp { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILFrameMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,12 +22,9 @@ */ package com.oracle.graal.lir.hsail; -import static com.oracle.graal.api.code.ValueUtil.*; - import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.*; -import com.oracle.graal.lir.hsail.HSAILMove.*; /** * HSAIL specific frame map. @@ -72,15 +69,4 @@ protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } - - @Override - public LIRInstruction createSpillMove(AllocatableValue dst, Value src) { - if (src instanceof HSAILAddressValue) { - return new LeaOp(dst, (HSAILAddressValue) src); - } else if (isRegister(src) || isStackSlot(dst)) { - return new MoveFromRegOp(dst, src); - } else { - return new MoveToRegOp(dst, src); - } - } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Mon Mar 17 14:30:59 2014 +0100 @@ -237,13 +237,6 @@ throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to object ref"); } break; - case NarrowOop: - if (input.isNull()) { - masm.emitStoreImmediate(kind, 0L, address.toAddress()); - } else { - throw GraalInternalError.shouldNotReachHere("Cannot store 64-bit constants to object ref"); - } - break; default: throw GraalInternalError.shouldNotReachHere(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXFrameMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,7 +24,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.graph.*; import com.oracle.graal.lir.*; /** @@ -70,10 +69,4 @@ protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } - - @Override - public LIRInstruction createSpillMove(AllocatableValue result, Value input) { - throw GraalInternalError.shouldNotReachHere("Spill moves should never be necessary for PTX code"); - } - } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCFrameMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -101,9 +101,4 @@ protected StackSlot allocateNewSpillSlot(PlatformKind kind, int additionalOffset) { return StackSlot.get(kind, -spillSize + additionalOffset, true); } - - @Override - public LIRInstruction createSpillMove(AllocatableValue result, Value input) { - return SPARCMove.createMove(result, input); - } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java --- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Mon Mar 17 14:30:59 2014 +0100 @@ -39,16 +39,6 @@ public class SPARCMove { - public static SPARCLIRInstruction createMove(AllocatableValue dst, Value src) { - if (src instanceof SPARCAddressValue) { - return new LoadAddressOp(dst, (SPARCAddressValue) src); - } else if (isRegister(src) || isStackSlot(dst)) { - return new MoveFromRegOp(dst, src); - } else { - return new MoveToRegOp(dst, src); - } - } - @Opcode("MOVE") public static class MoveToRegOp extends SPARCLIRInstruction implements MoveOp { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/FrameMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -170,7 +170,7 @@ // Without this, frameNeedsAllocating() would never return true. int total = 0; for (StackSlot s : freedSlots) { - total += target.arch.getSizeInBytes(s.getKind()); + total += target.getSizeInBytes(s.getKind()); } if (total == spillSize - initialSpillSize) { // reset spill area size @@ -256,7 +256,7 @@ * @return the size in bytes */ protected int spillSlotSize(PlatformKind kind) { - return target.arch.getSizeInBytes(kind); + return target.getSizeInBytes(kind); } /** @@ -347,8 +347,8 @@ } } - public ReferenceMap initReferenceMap(boolean canHaveRegisters) { - ReferenceMap refMap = new ReferenceMap(canHaveRegisters ? target.arch.getRegisterReferenceMapBitCount() : 0, frameSize() / target.wordSize); + public ReferenceMap initReferenceMap(boolean hasRegisters) { + ReferenceMap refMap = target.createReferenceMap(hasRegisters, frameSize() / target.wordSize); for (StackSlot slot : objectStackSlots) { setReference(slot, refMap); } @@ -364,24 +364,14 @@ * @param refMap A reference map, as created by {@link #initReferenceMap(boolean)}. */ public void setReference(Value location, ReferenceMap refMap) { - Kind kind = location.getKind(); - if (kind == Kind.Object || kind == Kind.NarrowOop) { - if (isRegister(location)) { - refMap.setRegister(asRegister(location).number, kind == Kind.NarrowOop); - } else if (isStackSlot(location)) { - if (kind == Kind.NarrowOop) { - int offset = offsetForStackSlot(asStackSlot(location)); - assert offset % target.wordSize == 0 || offset % target.wordSize == target.wordSize / 2; - refMap.setStackSlot(offset / target.wordSize, offset % target.wordSize == 0, offset % target.wordSize != 0); - } else { - int index = indexForStackSlot(asStackSlot(location)); - refMap.setStackSlot(index, false, false); - } - } else { - assert isConstant(location); - } + PlatformKind kind = location.getPlatformKind(); + if (isRegister(location)) { + refMap.setRegister(asRegister(location).number, kind); + } else if (isStackSlot(location)) { + int offset = offsetForStackSlot(asStackSlot(location)); + refMap.setStackSlot(offset, kind); + } else { + assert isConstant(location); } } - - public abstract LIRInstruction createSpillMove(AllocatableValue result, Value input); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,9 +24,9 @@ import java.util.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.lir.LIRInstruction.StateProcedure; import com.oracle.graal.lir.StandardOp.BlockEndOp; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; /** @@ -35,13 +35,7 @@ */ public class LIR { - public final ControlFlowGraph cfg; - - /** - * The nodes for the blocks. TODO: This should go away, we want all nodes connected with a - * next-pointer. - */ - private final BlockMap> blockToNodesMap; + private final ControlFlowGraph cfg; /** * The linear-scan ordered list of blocks. @@ -57,26 +51,29 @@ private int numVariables; - public final BlockMap> lirInstructions; + private SpillMoveFactory spillMoveFactory; + + private final BlockMap> lirInstructions; + + public interface SpillMoveFactory { + + LIRInstruction createMove(AllocatableValue result, Value input); + } private boolean hasArgInCallerFrame; /** * Creates a new LIR instance for the specified compilation. */ - public LIR(ControlFlowGraph cfg, BlockMap> blockToNodesMap, List linearScanOrder, List codeEmittingOrder) { + public LIR(ControlFlowGraph cfg, List linearScanOrder, List codeEmittingOrder) { this.cfg = cfg; - this.blockToNodesMap = blockToNodesMap; this.codeEmittingOrder = codeEmittingOrder; this.linearScanOrder = linearScanOrder; this.lirInstructions = new BlockMap<>(cfg); } - /** - * Gets the nodes in a given block. - */ - public List nodesFor(Block block) { - return blockToNodesMap.get(block); + public ControlFlowGraph getControlFlowGraph() { + return cfg; } /** @@ -93,7 +90,11 @@ return false; } - public List lir(Block block) { + public SpillMoveFactory getSpillMoveFactory() { + return spillMoveFactory; + } + + public List lir(AbstractBlock block) { return lirInstructions.get(block); } @@ -206,4 +207,8 @@ } return true; } + + public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) { + this.spillMoveFactory = spillMoveFactory; + } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Mon Mar 17 14:30:59 2014 +0100 @@ -38,9 +38,9 @@ */ public final class RedundantMoveElimination { - public static void optimize(LIR lir, FrameMap frameMap, ResolvedJavaMethod method) { + public static void optimize(LIR lir, FrameMap frameMap) { RedundantMoveElimination redundantMoveElimination = new RedundantMoveElimination(); - redundantMoveElimination.doOptimize(lir, frameMap, method); + redundantMoveElimination.doOptimize(lir, frameMap); } /** @@ -100,9 +100,9 @@ /** * The main method doing the elimination of redundant moves. */ - private void doOptimize(LIR lir, FrameMap frameMap, ResolvedJavaMethod method) { + private void doOptimize(LIR lir, FrameMap frameMap) { - try (Indent indent = Debug.logAndIndent("eliminate redundant moves in %s", method)) { + try (Indent indent = Debug.logAndIndent("eliminate redundant moves")) { callerSaveRegs = frameMap.registerConfig.getCallerSaveRegisters(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,7 +27,6 @@ import java.util.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.ConstantData; import com.oracle.graal.api.code.CompilationResult.Data; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; @@ -157,6 +156,10 @@ } public void recordInlineDataInCode(Constant data) { + recordInlineDataInCode(codeCache.createDataItem(data, 0)); + } + + public void recordInlineDataInCode(Data data) { assert data != null; int pos = asm.position(); Debug.log("Inline data in code: pos = %d, data = %s", pos, data); @@ -165,7 +168,7 @@ public AbstractAddress recordDataReferenceInCode(Constant data, int alignment) { assert data != null; - return recordDataReferenceInCode(new ConstantData(data, alignment)); + return recordDataReferenceInCode(codeCache.createDataItem(data, alignment)); } public AbstractAddress recordDataReferenceInCode(Data data) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Mon Mar 17 14:30:59 2014 +0100 @@ -28,7 +28,6 @@ import com.oracle.graal.graph.Graph.DuplicationReplacement; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.VirtualState.NodeClosure; import com.oracle.graal.nodes.VirtualState.VirtualClosure; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.java.*; @@ -302,6 +301,24 @@ exitState = exitState.duplicateWithVirtualState(); earlyExit.setStateAfter(exitState); merge.setStateAfter(state); + /* + * Using the old exit's state as the merge's state is necessary because some of the + * VirtualState nodes contained in the old exit's state may be shared by other + * dominated VirtualStates. Those dominated virtual states need to see the + * proxy->phi update that are applied below. + * + * We now update the original fragment's nodes accordingly: + */ + state.applyToVirtual(new VirtualClosure() { + public void apply(VirtualState node) { + original.nodes.clear(node); + } + }); + exitState.applyToVirtual(new VirtualClosure() { + public void apply(VirtualState node) { + original.nodes.mark(node); + } + }); } for (Node anchored : earlyExit.anchored().snapshot()) { @@ -315,7 +332,7 @@ PhiNode phi; switch (vpn.type()) { case Value: - phi = graph.addWithoutUnique(new PhiNode(vpn.kind(), merge)); + phi = graph.addWithoutUnique(new PhiNode(vpn.stamp(), merge)); break; case Guard: phi = graph.addWithoutUnique(new PhiNode(vpn.type(), merge)); @@ -332,17 +349,6 @@ } else { replaceWith = vpn.value(); } - if (state != null) { - state.applyToNonVirtual(new NodeClosure() { - - @Override - public void apply(Node from, ValueNode node) { - if (node == vpn) { - from.replaceFirstInput(vpn, replaceWith); - } - } - }); - } for (Node usage : vpn.usages().snapshot()) { if (!merge.isPhiAtMerge(usage)) { if (usage instanceof VirtualState) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Mar 17 14:30:59 2014 +0100 @@ -170,7 +170,7 @@ PhiNode ret; switch (phi.type()) { case Value: - ret = new PhiNode(phi.kind(), merge); + ret = new PhiNode(phi.stamp(), merge); break; case Guard: ret = new PhiNode(PhiType.Guard, merge); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -222,7 +222,8 @@ } } else if (b instanceof InstanceOfNode) { InstanceOfNode instanceOfB = (InstanceOfNode) b; - if (instanceOfA.object() == instanceOfB.object() && !instanceOfA.type().isAssignableFrom(instanceOfB.type()) && !instanceOfB.type().isAssignableFrom(instanceOfA.type())) { + if (instanceOfA.object() == instanceOfB.object() && !instanceOfA.type().isInterface() && !instanceOfB.type().isInterface() && + !instanceOfA.type().isAssignableFrom(instanceOfB.type()) && !instanceOfB.type().isAssignableFrom(instanceOfA.type())) { // Two instanceof on the same value with mutually exclusive types. JavaTypeProfile profileA = instanceOfA.profile(); JavaTypeProfile profileB = instanceOfB.profile(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,7 +22,6 @@ */ package com.oracle.graal.nodes; -import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.calc.*; @@ -53,15 +52,11 @@ private final PhiType type; /** - * Create a value phi ({@link PhiType#Value}) with the specified kind. + * Create a value phi ({@link PhiType#Value}) with the specified stamp. * - * @param kind the kind of the value + * @param stamp the stamp of the value * @param merge the merge that the new phi belongs to */ - public PhiNode(Kind kind, MergeNode merge) { - this(StampFactory.forKind(kind), merge); - } - public PhiNode(Stamp stamp, MergeNode merge) { super(stamp); assert stamp != StampFactory.forVoid(); @@ -186,7 +181,7 @@ public void addInput(ValueNode x) { assert !(x instanceof PhiNode) || ((PhiNode) x).merge() instanceof LoopBeginNode || ((PhiNode) x).merge() != this.merge(); - assert x.kind() == kind() || type != PhiType.Value; + assert x.stamp().isCompatible(stamp()) || type != PhiType.Value; values.add(x); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java Mon Mar 17 14:30:59 2014 +0100 @@ -71,8 +71,6 @@ private static final AtomicLong uniqueGraphIds = new AtomicLong(); - private final Set leafGraphIds = new HashSet<>(4); - private StartNode start; private final ResolvedJavaMethod method; private final long graphId; @@ -162,14 +160,6 @@ this.start = start; } - /** - * @return the {@link Set} that contains the {@link #graphId()} of all graphs that were - * incorporated into this one (e.g. by inlining). - */ - public Set getLeafGraphIds() { - return leafGraphIds; - } - @Override public StructuredGraph copy() { return copy(name); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/TypeProfileProxyNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.nodes; +import java.util.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; @@ -102,7 +104,7 @@ Debug.log("Profile useless, there is enough static type information available."); return object; } - if (type == lastCheckedType) { + if (Objects.equals(type, lastCheckedType)) { // We have already incorporate the knowledge about this type => abort. return this; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/CompareNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -54,7 +54,7 @@ * @param y the instruction that produces the second input to this instruction */ public CompareNode(ValueNode x, ValueNode y) { - assert (x == null && y == null) || x.kind() == y.kind(); + assert x != null && y != null && x.kind() == y.kind(); this.x = x; this.y = y; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerConvertNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.nodes.calc; import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.spi.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -30,7 +31,7 @@ /** * An {@code IntegerConvert} converts an integer to an integer of different width. */ -public abstract class IntegerConvertNode extends ConvertNode implements ArithmeticLIRLowerable { +public abstract class IntegerConvertNode extends ConvertNode implements ArithmeticLIRLowerable, Canonicalizable { private final int resultBits; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerTestNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerTestNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerTestNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -53,7 +53,7 @@ * @param y the instruction that produces the second input to this instruction */ public IntegerTestNode(ValueNode x, ValueNode y) { - assert (x == null && y == null) || x.stamp().isCompatible(y.stamp()); + assert x != null && y != null && x.stamp().isCompatible(y.stamp()); this.x = x; this.y = y; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/NarrowNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -32,7 +32,7 @@ /** * The {@code NarrowNode} converts an integer to a narrower integer. */ -public class NarrowNode extends IntegerConvertNode implements Simplifiable { +public class NarrowNode extends IntegerConvertNode { public NarrowNode(ValueNode input, int resultBits) { super(StampTool.narrowingConversion(input.stamp(), resultBits), input, resultBits); @@ -64,7 +64,8 @@ return false; } - private ValueNode tryCanonicalize() { + @Override + public Node canonical(CanonicalizerTool tool) { ValueNode ret = canonicalConvert(); if (ret != null) { return ret; @@ -99,35 +100,7 @@ } } - return null; - } - - private boolean tryNarrow(SimplifierTool tool, Stamp stamp, ValueNode node) { - boolean canNarrow = node instanceof NarrowableArithmeticNode && node.usages().count() == 1; - - if (canNarrow) { - for (Node inputNode : node.inputs().snapshot()) { - ValueNode input = (ValueNode) inputNode; - if (!tryNarrow(tool, stamp, input)) { - ValueNode narrow = graph().unique(new NarrowNode(input, getResultBits())); - node.replaceFirstInput(input, narrow); - tool.addToWorkList(narrow); - } - } - node.setStamp(stamp); - } - - return canNarrow; - } - - @Override - public void simplify(SimplifierTool tool) { - ValueNode ret = tryCanonicalize(); - if (ret != null) { - graph().replaceFloating(this, ret); - } else if (tryNarrow(tool, stamp().unrestricted(), getInput())) { - graph().replaceFloating(this, getInput()); - } + return this; } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -117,7 +117,7 @@ } else if (!xIdentity && !yIdentity) { // both are virtual without identity: check contents assert stateX.getVirtualObject().entryCount() == 1 && stateY.getVirtualObject().entryCount() == 1; - assert stateX.getVirtualObject().type() == stateY.getVirtualObject().type(); + assert stateX.getVirtualObject().type().equals(stateY.getVirtualObject().type()); assert stateX.getVirtualObject().entryKind(0).getStackKind() == Kind.Int || stateX.getVirtualObject().entryKind(0) == Kind.Long; IntegerEqualsNode equals = new IntegerEqualsNode(stateX.getEntry(0), stateY.getEntry(0)); tool.addNode(equals); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/SignExtendNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -32,7 +32,7 @@ /** * The {@code SignExtendNode} converts an integer to a wider integer using sign extension. */ -public class SignExtendNode extends IntegerConvertNode implements Canonicalizable { +public class SignExtendNode extends IntegerConvertNode { public SignExtendNode(ValueNode input, int resultBits) { super(StampTool.signExtend(input.stamp(), resultBits), input, resultBits); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ZeroExtendNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -32,7 +32,7 @@ /** * The {@code ZeroExtendNode} converts an integer to a wider integer using zero extension. */ -public class ZeroExtendNode extends IntegerConvertNode implements Canonicalizable { +public class ZeroExtendNode extends IntegerConvertNode { public ZeroExtendNode(ValueNode input, int resultBits) { super(StampTool.zeroExtend(input.stamp(), resultBits), input, resultBits); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/AbstractBlock.java Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.nodes.cfg; + +import com.oracle.graal.nodes.*; + +public interface AbstractBlock> { + + int getId(); + + AbstractBeginNode getBeginNode(); + + Loop getLoop(); + + int getLoopDepth(); + + boolean isLoopHeader(); + + boolean isLoopEnd(); + + boolean isExceptionEntry(); + + Iterable getPredecessors(); + + int getPredecessorCount(); + + Iterable getSuccessors(); + + int getSuccessorCount(); + + int getLinearScanNumber(); + + void setLinearScanNumber(int linearScanNumber); + + boolean isAligned(); + + void setAlign(boolean align); +} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/Block.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,7 +27,7 @@ import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; -public final class Block { +public final class Block implements AbstractBlock { protected final AbstractBeginNode beginNode; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/cfg/BlockMap.java Mon Mar 17 14:30:59 2014 +0100 @@ -31,11 +31,11 @@ data = (T[]) new Object[cfg.getBlocks().length]; } - public T get(Block block) { + public T get(AbstractBlock block) { return data[block.getId()]; } - public void put(Block block, T value) { + public void put(AbstractBlock block, T value) { data[block.getId()] = value; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -76,7 +76,7 @@ } if (tool.canonicalizeReads()) { if (metaAccess != null && object != null && object.isConstant()) { - if ((location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION || location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION) & + if ((location.getLocationIdentity() == LocationIdentity.FINAL_LOCATION || location.getLocationIdentity() == LocationIdentity.ARRAY_LENGTH_LOCATION) && location instanceof ConstantLocationNode) { long displacement = ((ConstantLocationNode) location).getDisplacement(); Kind kind = location.getValueKind(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnboxNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -60,7 +60,7 @@ if (state != null && state.getState() == EscapeState.Virtual) { ResolvedJavaType objectType = state.getVirtualObject().type(); ResolvedJavaType expectedType = tool.getMetaAccessProvider().lookupJavaType(boxingKind.toBoxedJavaClass()); - if (objectType == expectedType) { + if (objectType.equals(expectedType)) { tool.replaceWithValue(state.getEntry(0)); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -165,7 +165,7 @@ } if (tool.assumptions() != null && tool.assumptions().useOptimisticAssumptions()) { ResolvedJavaType exactType = type.findUniqueConcreteSubtype(); - if (exactType != null && exactType != type) { + if (exactType != null && !exactType.equals(type)) { // Propagate more precise type information to usages of the checkcast. tool.assumptions().recordConcreteSubtype(type, exactType); return graph().add(new CheckCastNode(exactType, object, profile, forStoreCheck)); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -165,7 +165,7 @@ public static MethodCallTargetNode find(StructuredGraph graph, ResolvedJavaMethod method) { for (MethodCallTargetNode target : graph.getNodes(MethodCallTargetNode.class)) { - if (target.targetMethod == method) { + if (target.targetMethod.equals(method)) { return target; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/GraphCache.java Mon Mar 17 14:29:45 2014 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.nodes.spi; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; - -/** - * A cache for graphs associated with {@linkplain StructuredGraph#method() methods}. - */ -public interface GraphCache { - - /** - * Requests that a graph be added to this cache. - * - * @param hasMatureProfilingInfo indicates that the caller has - * {@linkplain ProfilingInfo#isMature() mature} profiling info for the method - * associated with the graph - * @return true if {@code graph} was added to this cache, false otherwise - */ - boolean put(StructuredGraph graph, boolean hasMatureProfilingInfo); - - /** - * Gets the graph from this cache associated with a given method. - * - * @param method a method for which a cached graph is requested - * @return the graph cached for {@code method} or null if it does not exist - */ - StructuredGraph get(ResolvedJavaMethod method); - - /** - * The cache will remove graphs it considers stale. For example, graphs associated with - * installed code that has subsequently be deoptimized might be considered stale. - */ - void removeStaleGraphs(); -} diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IllegalStamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IllegalStamp.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/IllegalStamp.java Mon Mar 17 14:30:59 2014 +0100 @@ -85,8 +85,9 @@ if (stamp instanceof IllegalStamp) { IllegalStamp other = (IllegalStamp) stamp; return kind == other.kind; + } else { + return stamp.isCompatible(this); } - return false; } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/ObjectStamp.java Mon Mar 17 14:30:59 2014 +0100 @@ -119,14 +119,14 @@ meetAlwaysNull = other.alwaysNull; } else { meetType = meetTypes(type(), other.type()); - meetExactType = meetType == type && meetType == other.type && exactType && other.exactType; + meetExactType = Objects.equals(meetType, type) && Objects.equals(meetType, other.type) && exactType && other.exactType; meetNonNull = nonNull && other.nonNull; meetAlwaysNull = false; } - if (meetType == type && meetExactType == exactType && meetNonNull == nonNull && meetAlwaysNull == alwaysNull) { + if (Objects.equals(meetType, type) && meetExactType == exactType && meetNonNull == nonNull && meetAlwaysNull == alwaysNull) { return this; - } else if (meetType == other.type && meetExactType == other.exactType && meetNonNull == other.nonNull && meetAlwaysNull == other.alwaysNull) { + } else if (Objects.equals(meetType, other.type) && meetExactType == other.exactType && meetNonNull == other.nonNull && meetAlwaysNull == other.alwaysNull) { return other; } else { return new ObjectStamp(meetType, meetExactType, meetNonNull, meetAlwaysNull); @@ -186,7 +186,7 @@ boolean joinAlwaysNull = alwaysNull || other.alwaysNull; boolean joinNonNull = nonNull || other.nonNull; boolean joinExactType = exactType || other.exactType; - if (type == other.type) { + if (Objects.equals(type, other.type)) { joinType = type; } else if (type == null && other.type == null) { joinType = null; @@ -230,9 +230,9 @@ } else if (joinExactType && !isConcreteType(joinType)) { return StampFactory.illegal(Kind.Object); } - if (joinType == type && joinExactType == exactType && joinNonNull == nonNull && joinAlwaysNull == alwaysNull) { + if (Objects.equals(joinType, type) && joinExactType == exactType && joinNonNull == nonNull && joinAlwaysNull == alwaysNull) { return this; - } else if (joinType == other.type && joinExactType == other.exactType && joinNonNull == other.nonNull && joinAlwaysNull == other.alwaysNull) { + } else if (Objects.equals(joinType, other.type) && joinExactType == other.exactType && joinNonNull == other.nonNull && joinAlwaysNull == other.alwaysNull) { return other; } else { return new ObjectStamp(joinType, joinExactType, joinNonNull, joinAlwaysNull); @@ -244,7 +244,7 @@ } private static ResolvedJavaType meetTypes(ResolvedJavaType a, ResolvedJavaType b) { - if (a == b) { + if (Objects.equals(a, b)) { return a; } else if (a == null || b == null) { return null; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java Mon Mar 17 14:30:59 2014 +0100 @@ -240,7 +240,7 @@ assert type.getKind() == Kind.Object; ResolvedJavaType exact = type.asExactType(); if (exact != null) { - assert !exactType || type == exact; + assert !exactType || type.equals(exact); return new ObjectStamp(exact, true, nonNull, false); } else { return new ObjectStamp(type, exactType, nonNull, false); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/util/NodesToDoubles.java diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/virtual/VirtualInstanceNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -77,7 +77,7 @@ public int fieldIndex(ResolvedJavaField field) { // on average fields.length == ~6, so a linear search is fast enough for (int i = 0; i < fields.length; i++) { - if (fields[i] == field) { + if (fields[i].equals(field)) { return i; } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java --- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionProcessor.java Mon Mar 17 14:30:59 2014 +0100 @@ -172,7 +172,7 @@ String declaringClass = option.declaringClass; Name fieldName = option.field.getSimpleName(); String comma = i == info.options.size() - 1 ? "" : ","; - out.printf(" new %s(\"%s\", %s.class, \"%s\", %s.class, \"%s\", %s)%s\n", desc, name, type, help, declaringClass, fieldName, optionValue, comma); + out.printf(" new %s(\"%s\", %s.class, \"%s\", %s.class, \"%s\", %s)%s%n", desc, name, type, help, declaringClass, fieldName, optionValue, comma); i++; } out.println(" );"); @@ -264,7 +264,7 @@ private static Element topDeclaringType(Element element) { Element enclosing = element.getEnclosingElement(); - if (element == null || enclosing.getKind() == ElementKind.PACKAGE) { + if (enclosing == null || enclosing.getKind() == ElementKind.PACKAGE) { assert element.getKind() == ElementKind.CLASS || element.getKind() == ElementKind.INTERFACE; return element; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -294,7 +294,7 @@ FixedNode fixed = (FixedNode) node; if (canonical instanceof ControlSinkNode) { // case 7 - fixed.predecessor().replaceFirstSuccessor(fixed, canonical); + fixed.replaceAtPredecessor(canonical); GraphUtil.killCFG(fixed); return true; } else { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -66,7 +66,7 @@ new ConditionalElimination(graph.start(), new State()).apply(); } - public static class State extends MergeableState { + public static class State extends MergeableState implements Cloneable { private IdentityHashMap knownTypes; private HashSet knownNonNull; @@ -253,7 +253,7 @@ ResolvedJavaType knownType = getNodeType(original); ResolvedJavaType newType = tighten(type, knownType); - if (newType != knownType) { + if (!newType.equals(knownType)) { knownTypes.put(original, newType); metricTypeRegistered.increment(); } @@ -271,7 +271,7 @@ public static ResolvedJavaType widen(ResolvedJavaType a, ResolvedJavaType b) { if (a == null || b == null) { return null; - } else if (a == b) { + } else if (a.equals(b)) { return a; } else { return a.findLeastCommonAncestor(b); @@ -283,7 +283,7 @@ return b; } else if (b == null) { return a; - } else if (a == b) { + } else if (a.equals(b)) { return a; } else if (a.isAssignableFrom(b)) { return b; @@ -623,7 +623,7 @@ ValueNode receiver = callTarget.receiver(); if (receiver != null && (callTarget.invokeKind() == InvokeKind.Interface || callTarget.invokeKind() == InvokeKind.Virtual)) { ResolvedJavaType type = state.getNodeType(receiver); - if (type != ObjectStamp.typeOrNull(receiver)) { + if (!Objects.equals(type, ObjectStamp.typeOrNull(receiver))) { ResolvedJavaMethod method = type.resolveMethod(callTarget.targetMethod()); if (method != null) { if (Modifier.isFinal(method.getModifiers()) || Modifier.isFinal(type.getModifiers())) { @@ -645,7 +645,7 @@ for (Node n : value.usages()) { if (n instanceof InstanceOfNode) { InstanceOfNode instanceOfNode = (InstanceOfNode) n; - if (instanceOfNode.type() == type && state.trueConditions.containsKey(instanceOfNode)) { + if (instanceOfNode.type().equals(type) && state.trueConditions.containsKey(instanceOfNode)) { ValueNode v = state.trueConditions.get(instanceOfNode); if (v instanceof GuardingNode) { return (GuardingNode) v; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DeoptimizationGroupingPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,6 +27,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; @@ -55,8 +56,8 @@ if (target instanceof AbstractDeoptimizeNode) { merge = graph.add(new MergeNode()); EndNode firstEnd = graph.add(new EndNode()); - reasonActionPhi = graph.addWithoutUnique(new PhiNode(Kind.Int, merge)); - speculationPhi = graph.addWithoutUnique(new PhiNode(Kind.Object, merge)); + reasonActionPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Int), merge)); + speculationPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), merge)); merge.addForwardEnd(firstEnd); reasonActionPhi.addInput(((AbstractDeoptimizeNode) target).getActionAndReason(context.getMetaAccess())); speculationPhi.addInput(((AbstractDeoptimizeNode) target).getSpeculation(context.getMetaAccess())); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -59,8 +59,9 @@ if (node instanceof StateSplit) { StateSplit stateSplit = (StateSplit) node; - if (stateSplit.stateAfter() != null) { - FrameState newState = stateSplit.stateAfter(); + FrameState stateAfter = stateSplit.stateAfter(); + if (stateAfter != null) { + FrameState newState = stateAfter; stateSplit.setStateAfter(null); return newState; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -91,14 +91,6 @@ return inliningCount; } - public static void storeStatisticsAfterLowTier(StructuredGraph graph) { - ResolvedJavaMethod method = graph.method(); - if (method != null) { - CompiledMethodInfo info = compiledMethodInfo(graph.method()); - info.setLowLevelNodeCount(graph.getNodeCount()); - } - } - @Override protected void run(final StructuredGraph graph, final HighTierContext context) { final InliningData data = new InliningData(graph, context.getAssumptions()); @@ -281,7 +273,7 @@ } private static StructuredGraph getCachedGraph(ResolvedJavaMethod method, HighTierContext context) { - if (CacheGraphs.getValue() && context.getGraphCache() != null) { + if (context.getGraphCache() != null) { StructuredGraph cachedGraph = context.getGraphCache().get(method); if (cachedGraph != null) { return cachedGraph; @@ -304,21 +296,12 @@ canonicalizer.apply(newGraph, context); } - if (CacheGraphs.getValue() && context.getGraphCache() != null) { - context.getGraphCache().put(newGraph.copy(), hasMatureProfilingInfo); + if (hasMatureProfilingInfo && context.getGraphCache() != null) { + context.getGraphCache().put(newGraph.method(), newGraph.copy()); } return newGraph; } - private static synchronized CompiledMethodInfo compiledMethodInfo(ResolvedJavaMethod m) { - CompiledMethodInfo info = (CompiledMethodInfo) m.getCompilerStorage().get(CompiledMethodInfo.class); - if (info == null) { - info = new CompiledMethodInfo(); - m.getCompilerStorage().put(CompiledMethodInfo.class, info); - } - return info; - } - private abstract static class AbstractInliningPolicy implements InliningPolicy { protected final Map hints; @@ -371,7 +354,12 @@ protected static int previousLowLevelGraphSize(InlineInfo info) { int size = 0; for (int i = 0; i < info.numberOfMethods(); i++) { - size += compiledMethodInfo(info.methodAt(i)).lowLevelNodeCount(); + ResolvedJavaMethod m = info.methodAt(i); + ProfilingInfo profile = m.getProfilingInfo(); + int compiledGraphSize = profile.getCompilerIRSize(StructuredGraph.class); + if (compiledGraphSize > 0) { + size += compiledGraphSize; + } } return size; } @@ -864,21 +852,4 @@ return (graph != null ? MetaUtil.format("%H.%n(%p)", method()) : "") + remainingInvokes; } } - - private static class CompiledMethodInfo { - - private int lowLevelNodes; - - public CompiledMethodInfo() { - } - - public int lowLevelNodeCount() { - return lowLevelNodes; - } - - public void setLowLevelNodeCount(int lowLevelNodes) { - this.lowLevelNodes = lowLevelNodes; - } - - } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Mon Mar 17 14:30:59 2014 +0100 @@ -318,14 +318,9 @@ } protected static void inline(Invoke invoke, ResolvedJavaMethod concrete, Inlineable inlineable, Assumptions assumptions, boolean receiverNullCheck) { - StructuredGraph graph = invoke.asNode().graph(); if (inlineable instanceof InlineableGraph) { StructuredGraph calleeGraph = ((InlineableGraph) inlineable).getGraph(); InliningUtil.inline(invoke, calleeGraph, receiverNullCheck); - - graph.getLeafGraphIds().add(calleeGraph.graphId()); - // we might at some point cache already-inlined graphs, so add recursively: - graph.getLeafGraphIds().addAll(calleeGraph.getLeafGraphIds()); } else { assert inlineable instanceof InlineableMacroNode; @@ -630,7 +625,7 @@ PhiNode returnValuePhi = null; if (invoke.asNode().kind() != Kind.Void) { - returnValuePhi = graph.addWithoutUnique(new PhiNode(invoke.asNode().kind(), returnMerge)); + returnValuePhi = graph.addWithoutUnique(new PhiNode(invoke.asNode().stamp().unrestricted(), returnMerge)); } MergeNode exceptionMerge = null; @@ -643,7 +638,7 @@ FixedNode exceptionSux = exceptionEdge.next(); graph.addBeforeFixed(exceptionSux, exceptionMerge); - exceptionObjectPhi = graph.addWithoutUnique(new PhiNode(Kind.Object, exceptionMerge)); + exceptionObjectPhi = graph.addWithoutUnique(new PhiNode(StampFactory.forKind(Kind.Object), exceptionMerge)); exceptionMerge.setStateAfter(exceptionEdge.stateAfter().duplicateModified(invoke.stateAfter().bci, true, Kind.Object, exceptionObjectPhi)); } @@ -1434,7 +1429,7 @@ } else { // only handle the outermost frame states if (frameState.outerFrameState() == null) { - assert frameState.bci == FrameState.INVALID_FRAMESTATE_BCI || frameState.method() == inlineGraph.method(); + assert frameState.bci == FrameState.INVALID_FRAMESTATE_BCI || frameState.method().equals(inlineGraph.method()); if (outerFrameState == null) { outerFrameState = stateAfter.duplicateModified(invoke.bci(), stateAfter.rethrowException(), invokeNode.kind()); outerFrameState.setDuringCall(true); @@ -1491,7 +1486,7 @@ if (returnNode.result() != null) { if (returnValuePhi == null) { - returnValuePhi = merge.graph().addWithoutUnique(new PhiNode(returnNode.result().kind(), merge)); + returnValuePhi = merge.graph().addWithoutUnique(new PhiNode(returnNode.result().stamp().unrestricted(), merge)); } returnValuePhi.addInput(returnNode.result()); } @@ -1545,7 +1540,7 @@ public static FixedWithNextNode inlineMacroNode(Invoke invoke, ResolvedJavaMethod concrete, Class macroNodeClass) throws GraalInternalError { StructuredGraph graph = invoke.asNode().graph(); - if (((MethodCallTargetNode) invoke.callTarget()).targetMethod() != concrete) { + if (!concrete.equals(((MethodCallTargetNode) invoke.callTarget()).targetMethod())) { assert ((MethodCallTargetNode) invoke.callTarget()).invokeKind() != InvokeKind.Static; InliningUtil.replaceInvokeCallTarget(invoke, graph, InvokeKind.Special, concrete); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -312,6 +312,8 @@ Mark preLoweringMark = node.graph().getMark(); ((Lowerable) node).lower(loweringTool); if (loweringTool.guardAnchor.asNode().isDeleted()) { + // TODO nextNode could be deleted but this is not currently supported + assert nextNode.isAlive(); loweringTool.guardAnchor = BeginNode.prevBegin(nextNode); } assert checkPostNodeLowering(node, loweringTool, preLoweringMark, unscheduledUsages); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ReadEliminationPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -87,7 +87,7 @@ } if (lastLocationAccess instanceof PhiNode) { PhiNode phi = (PhiNode) lastLocationAccess; - PhiNode newPhi = phi.graph().addWithoutUnique(new PhiNode(n.kind(), phi.merge())); + PhiNode newPhi = phi.graph().addWithoutUnique(new PhiNode(n.stamp().unrestricted(), phi.merge())); nodeMap.set(phi, newPhi); for (ValueNode value : phi.values()) { newPhi.addInput(getValue(n, (MemoryNode) value, nodeMap)); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -486,7 +486,7 @@ // introduce a new phi PhiNode newPhi = bottomPhis.get(node); if (newPhi == null) { - newPhi = graph.addWithoutUnique(new PhiNode(node.kind(), newBottomMerge)); + newPhi = graph.addWithoutUnique(new PhiNode(node.stamp().unrestricted(), newBottomMerge)); bottomPhis.put(node, newPhi); newPhi.addInput(node); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ValueAnchorCleanupPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -37,7 +37,7 @@ */ public class ValueAnchorCleanupPhase extends Phase { - private static class State extends MergeableState { + private static class State extends MergeableState implements Cloneable { private final HashSet anchoredValues; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Mon Mar 17 14:30:59 2014 +0100 @@ -92,10 +92,6 @@ // graph caching @Option(help = "") public static final OptionValue CacheGraphs = new OptionValue<>(true); - @Option(help = "") - public static final OptionValue GraphCacheSize = new OptionValue<>(1000); - @Option(help = "") - public static final OptionValue PrintGraphCache = new OptionValue<>(false); //loop transform settings TODO (gd) tune @Option(help = "") @@ -181,6 +177,8 @@ @Option(help = "") public static final OptionValue HotSpotPrintCompilation = new OptionValue<>(false); @Option(help = "") + public static final OptionValue HotSpotCIPrintCompilerName = new OptionValue<>(false); + @Option(help = "") public static final OptionValue HotSpotPrintInlining = new OptionValue<>(false); // Register allocator debugging diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/VerifyPhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -27,15 +27,35 @@ /*** * This phase serves as a verification, in order to check the graph for certain properties. The * {@link #verify(StructuredGraph, Object)} method will be used as an assertion, and implements the - * actual check. Instead of returning false, it is also valid to throw an {@link AssertionError} in - * the implemented {@link #verify(StructuredGraph, Object)} method. + * actual check. Instead of returning false, it is also valid to throw an {@link VerificationError} + * in the implemented {@link #verify(StructuredGraph, Object)} method. */ public abstract class VerifyPhase extends BasePhase { + /** + * Thrown when verification performed by a {@link VerifyPhase} fails. + */ + @SuppressWarnings("serial") + public static class VerificationError extends AssertionError { + + public VerificationError(String message) { + super(message); + } + + public VerificationError(String message, Throwable cause) { + super(message, cause); + } + } + @Override protected final void run(StructuredGraph graph, C context) { assert verify(graph, context); } + /** + * Performs the actual verification. + * + * @throws VerificationError if the verification fails + */ protected abstract boolean verify(StructuredGraph graph, C context); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ComputeProbabilityClosure.java Mon Mar 17 14:30:59 2014 +0100 @@ -169,7 +169,7 @@ public final NodeMap> requires; - private double loopFrequency = -1; + private double loopFrequency = -1.0; public boolean ended = false; public LoopInfo(LoopBeginNode loopBegin) { @@ -178,7 +178,8 @@ } public double loopFrequency(NodesToDoubles nodeProbabilities) { - if (loopFrequency == -1 && ended) { + // loopFrequency is initialized with -1.0 + if (loopFrequency < 0.0 && ended) { double backEdgeProb = 0.0; for (LoopEndNode le : loopBegin.loopEnds()) { double factor = 1; @@ -219,7 +220,7 @@ return r; } - private class Probability extends MergeableState { + private class Probability extends MergeableState implements Cloneable { public double probability; public Set loops; @@ -330,7 +331,7 @@ } } - private class LoopCount extends MergeableState { + private class LoopCount extends MergeableState implements Cloneable { public double count; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/MergeableState.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/MergeableState.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/MergeableState.java Mon Mar 17 14:30:59 2014 +0100 @@ -62,7 +62,7 @@ // empty default implementation } - public static final class EmptyState extends MergeableState { + public static final class EmptyState extends MergeableState implements Cloneable { @Override public EmptyState clone() { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Mar 17 14:30:59 2014 +0100 @@ -292,7 +292,7 @@ } private void printSchedule(String desc) { - if (Debug.isEnabled()) { + if (Debug.isLogEnabled()) { Debug.printf("=== %s / %s / %s (%s) ===\n", getCFG().getStartBlock().getBeginNode().graph(), selectedStrategy, memsched, desc); for (Block b : getCFG().getBlocks()) { Debug.printf("==== b: %s (loopDepth: %s). ", b, b.getLoopDepth()); @@ -388,8 +388,7 @@ private void assignBlockToNode(ScheduledNode node, SchedulingStrategy strategy) { assert !node.isDeleted(); - Block prevBlock = cfg.getNodeToBlock().get(node); - if (prevBlock != null) { + if (cfg.getNodeToBlock().containsKey(node)) { return; } // PhiNodes, ProxyNodes and FixedNodes should already have been placed in blocks by @@ -418,6 +417,7 @@ block = latestBlock(node, strategy); } if (block == null) { + // handle nodes without usages block = earliestBlock; } else if (strategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS && !(node instanceof VirtualObjectNode)) { // schedule at the latest position possible in the outermost loop possible @@ -752,10 +752,14 @@ if (!(usage instanceof FrameState)) { throw new SchedulingError(usage.toString()); } - // If a FrameState belongs to a BeginNode then it's inputs will be placed at the - // common dominator of all EndNodes. - for (Node pred : unscheduledUsage.cfgPredecessors()) { - closure.apply(cfg.getNodeToBlock().get(pred)); + if (unscheduledUsage instanceof StartNode) { + closure.apply(cfg.getNodeToBlock().get(unscheduledUsage)); + } else { + // If a FrameState belongs to a BeginNode then it's inputs will be placed at + // the common dominator of all EndNodes. + for (Node pred : unscheduledUsage.cfgPredecessors()) { + closure.apply(cfg.getNodeToBlock().get(pred)); + } } } else { // For the time being, FrameStates can only be connected to NodeWithState. diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Mon Mar 17 14:30:59 2014 +0100 @@ -22,8 +22,11 @@ */ package com.oracle.graal.phases.tiers; +import java.util.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.util.*; @@ -32,18 +35,19 @@ private final PhaseSuite graphBuilderSuite; - private final GraphCache cache; + private final Map cache; private final OptimisticOptimizations optimisticOpts; public HighTierContext(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, LoweringProvider lowerer, Replacements replacements, Assumptions assumptions, - GraphCache cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts) { + Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts) { super(metaAccess, constantReflection, lowerer, replacements, assumptions); this.cache = cache; this.graphBuilderSuite = graphBuilderSuite; this.optimisticOpts = optimisticOpts; } - public HighTierContext(Providers providers, Assumptions assumptions, GraphCache cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts) { + public HighTierContext(Providers providers, Assumptions assumptions, Map cache, PhaseSuite graphBuilderSuite, + OptimisticOptimizations optimisticOpts) { this(providers.getMetaAccess(), providers.getConstantReflection(), providers.getLowerer(), providers.getReplacements(), assumptions, cache, graphBuilderSuite, optimisticOpts); } @@ -51,7 +55,7 @@ return graphBuilderSuite; } - public GraphCache getGraphCache() { + public Map getGraphCache() { return cache; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/util/GraphOrder.java Mon Mar 17 14:30:59 2014 +0100 @@ -26,7 +26,12 @@ import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.VirtualState.NodeClosure; +import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.phases.graph.*; +import com.oracle.graal.phases.graph.ReentrantBlockIterator.*; +import com.oracle.graal.phases.schedule.*; +import com.oracle.graal.phases.schedule.SchedulePhase.*; public final class GraphOrder { @@ -34,9 +39,9 @@ } /** - * Asserts that there are no (invalid) cycles in the given graph. First, an ordered list of all - * nodes in the graph (a total ordering) is created. A second run over this list checks whether - * inputs are scheduled before their usages. + * Quick (and imprecise) assertion that there are no (invalid) cycles in the given graph. First, + * an ordered list of all nodes in the graph (a total ordering) is created. A second run over + * this list checks whether inputs are scheduled before their usages. * * @param graph the graph to be checked. * @throws AssertionError if a cycle was detected. @@ -62,7 +67,6 @@ } visited.mark(node); } - return true; } @@ -80,34 +84,161 @@ } private static void visitForward(ArrayList nodes, NodeBitMap visited, Node node, boolean floatingOnly) { - if (node != null && !visited.isMarked(node)) { - assert !floatingOnly || !(node instanceof FixedNode) : "unexpected reference to fixed node: " + node + " (this indicates an unexpected cycle)"; - visited.mark(node); - FrameState stateAfter = null; - if (node instanceof StateSplit) { - stateAfter = ((StateSplit) node).stateAfter(); - } - for (Node input : node.inputs()) { - if (input != stateAfter) { - visitForward(nodes, visited, input, true); + try { + assert node == null || node.isAlive() : node + " not alive"; + if (node != null && !visited.isMarked(node)) { + if (floatingOnly && node instanceof FixedNode) { + throw new GraalInternalError("unexpected reference to fixed node: %s (this indicates an unexpected cycle)", node); + } + visited.mark(node); + FrameState stateAfter = null; + if (node instanceof StateSplit) { + stateAfter = ((StateSplit) node).stateAfter(); + } + for (Node input : node.inputs()) { + if (input != stateAfter) { + visitForward(nodes, visited, input, true); + } + } + if (node instanceof EndNode) { + EndNode end = (EndNode) node; + for (PhiNode phi : end.merge().phis()) { + visitForward(nodes, visited, phi.valueAt(end), true); + } + } + nodes.add(node); + if (node instanceof MergeNode) { + for (PhiNode phi : ((MergeNode) node).phis()) { + visited.mark(phi); + nodes.add(phi); + } + } + if (stateAfter != null) { + visitForward(nodes, visited, stateAfter, true); } } - if (node instanceof EndNode) { - EndNode end = (EndNode) node; - for (PhiNode phi : end.merge().phis()) { - visitForward(nodes, visited, phi.valueAt(end), true); - } - } - nodes.add(node); - if (node instanceof MergeNode) { - for (PhiNode phi : ((MergeNode) node).phis()) { - visited.mark(phi); - nodes.add(phi); - } - } - if (stateAfter != null) { - visitForward(nodes, visited, stateAfter, true); - } + } catch (GraalInternalError e) { + e.addContext(node); + throw e; } } + + /** + * This method schedules the graph and makes sure that, for every node, all inputs are available + * at the position where it is scheduled. This is a very expensive assertion. + * + * Also, this phase assumes ProxyNodes to exist at LoopExitNodes, so that it cannot be run after + * phases that remove loop proxies or move proxies to BeginNodes. + */ + public static boolean assertSchedulableGraph(final StructuredGraph graph) { + try { + final SchedulePhase schedule = new SchedulePhase(SchedulingStrategy.LATEST_OUT_OF_LOOPS, MemoryScheduling.NONE); + final IdentityHashMap loopEntryStates = new IdentityHashMap<>(); + schedule.apply(graph, false); + + BlockIteratorClosure closure = new BlockIteratorClosure() { + + @Override + protected List processLoop(Loop loop, NodeBitMap initialState) { + return ReentrantBlockIterator.processLoop(this, loop, initialState).exitStates; + } + + @Override + protected NodeBitMap processBlock(final Block block, final NodeBitMap currentState) { + final List list = schedule.getBlockToNodesMap().get(block); + + /* + * A stateAfter is not valid directly after its associated state split, but + * right before the next fixed node. Therefore a pending stateAfter is kept that + * will be checked at the correct position. + */ + FrameState pendingStateAfter = null; + for (final ScheduledNode node : list) { + FrameState stateAfter = node instanceof StateSplit ? ((StateSplit) node).stateAfter() : null; + + if (pendingStateAfter != null && node instanceof FixedNode) { + pendingStateAfter.applyToNonVirtual(new NodeClosure() { + public void apply(Node usage, Node nonVirtualNode) { + assert currentState.isMarked(nonVirtualNode) : nonVirtualNode + " not available at virtualstate " + usage + " before " + node + " in block " + block + " \n" + list; + } + }); + pendingStateAfter = null; + } + + if (node instanceof MergeNode) { + // phis aren't scheduled, so they need to be added explicitly + currentState.markAll(((MergeNode) node).phis()); + if (node instanceof LoopBeginNode) { + // remember the state at the loop entry, it's restored at exits + loopEntryStates.put((LoopBeginNode) node, currentState.copy()); + } + } else if (node instanceof ProxyNode) { + for (Node input : node.inputs()) { + if (input != ((ProxyNode) node).proxyPoint()) { + assert currentState.isMarked(input) : input + " not available at " + node + " in block " + block + "\n" + list; + } + } + } else if (node instanceof LoopExitNode) { + // the contents of the loop are only accessible via proxies at the exit + currentState.clearAll(); + currentState.markAll(loopEntryStates.get(((LoopExitNode) node).loopBegin())); + // Loop proxies aren't scheduled, so they need to be added explicitly + currentState.markAll(((LoopExitNode) node).proxies()); + } else { + for (Node input : node.inputs()) { + if (input != stateAfter) { + assert currentState.isMarked(input) : input + " not available at " + node + " in block " + block + "\n" + list; + } + } + } + if (node instanceof AbstractEndNode) { + MergeNode merge = ((AbstractEndNode) node).merge(); + for (PhiNode phi : merge.phis()) { + assert currentState.isMarked(phi.valueAt((AbstractEndNode) node)) : phi.valueAt((AbstractEndNode) node) + " not available at phi " + phi + " / end " + node + + " in block " + block; + } + } + if (stateAfter != null) { + assert pendingStateAfter == null; + pendingStateAfter = stateAfter; + } + currentState.mark(node); + } + if (pendingStateAfter != null) { + pendingStateAfter.applyToNonVirtual(new NodeClosure() { + public void apply(Node usage, Node nonVirtualNode) { + assert currentState.isMarked(nonVirtualNode) : nonVirtualNode + " not available at virtualstate " + usage + " at end of block " + block + " \n" + list; + } + }); + } + return currentState; + } + + @Override + protected NodeBitMap merge(Block merge, List states) { + NodeBitMap result = states.get(0); + for (int i = 1; i < states.size(); i++) { + result.intersect(states.get(i)); + } + return result; + } + + @Override + protected NodeBitMap getInitialState() { + return graph.createNodeBitMap(); + } + + @Override + protected NodeBitMap cloneState(NodeBitMap oldState) { + return oldState.copy(); + } + }; + + ReentrantBlockIterator.apply(closure, schedule.getCFG().getStartBlock()); + + } catch (Throwable t) { + throw new AssertionError("unschedulable graph", t); + } + return true; + } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/verify/VerifyUsageWithEquals.java Mon Mar 17 14:30:59 2014 +0100 @@ -62,18 +62,13 @@ return isAssignableType(x, metaAccess) && !isNullConstant(y); } - private static boolean isEqualsMethod(StructuredGraph graph) { - Signature signature = graph.method().getSignature(); - return graph.method().getName().equals("equals") && signature.getParameterCount(false) == 1 && signature.getParameterKind(0).equals(Kind.Object); - } - @Override protected boolean verify(StructuredGraph graph, PhaseContext context) { for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) { - if (!isEqualsMethod(graph)) { - // bail out if we compare an object of type klass with == or != (except null checks) - assert !(checkUsage(cn.x(), cn.y(), context.getMetaAccess()) && checkUsage(cn.y(), cn.x(), context.getMetaAccess())) : "Verification of " + klass.getName() + - " usage failed: Comparing " + cn.x() + " and " + cn.y() + " in " + graph.method() + " must use .equals() for object equality, not '==' or '!='"; + // bail out if we compare an object of type klass with == or != (except null checks) + if (checkUsage(cn.x(), cn.y(), context.getMetaAccess()) && checkUsage(cn.y(), cn.x(), context.getMetaAccess())) { + throw new VerificationError("Verification of " + klass.getName() + " usage failed: Comparing " + cn.x() + " and " + cn.y() + " in " + graph.method() + + " must use .equals() for object equality, not '==' or '!='"); } } return true; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinter.java Mon Mar 17 14:30:59 2014 +0100 @@ -250,11 +250,8 @@ } } - if (lir != null) { - for (Node node : lir.nodesFor(block)) { - printNode(node, false); - } - } else { + // Currently no node printing for lir + if (lir == null) { Node cur = block.getBeginNode(); while (true) { printNode(cur, false); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Mon Mar 17 14:30:59 2014 +0100 @@ -141,7 +141,7 @@ cfgPrinter.target = cfgPrinter.lirGenerator.target(); } if (cfgPrinter.lir != null) { - cfgPrinter.cfg = cfgPrinter.lir.cfg; + cfgPrinter.cfg = cfgPrinter.lir.getControlFlowGraph(); } CodeCacheProvider codeCache = Debug.contextLookup(CodeCacheProvider.class); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CompilationPrinter.java Mon Mar 17 14:30:59 2014 +0100 @@ -134,16 +134,17 @@ */ protected String debugInfoToString(BytecodePosition codePos, ReferenceMap refMap, RegisterSaveLayout calleeSaveInfo, Architecture arch) { StringBuilder sb = new StringBuilder(); + RefMapFormatter formatter = new CodeUtil.NumberedRefMapFormatter(); if (refMap != null && refMap.hasRegisterRefMap()) { sb.append("reg-ref-map:"); - refMap.appendRegisterMap(sb, arch != null ? new ArchitectureRegFormatter(arch) : null); + refMap.appendRegisterMap(sb, arch != null ? new ArchitectureRegFormatter(arch) : formatter); sb.append("\n"); } if (refMap != null && refMap.hasFrameRefMap()) { sb.append("frame-ref-map:"); - refMap.appendFrameMap(sb, null); + refMap.appendFrameMap(sb, formatter); sb.append("\n"); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/DecompilerDebugDumpHandler.java Mon Mar 17 14:30:59 2014 +0100 @@ -35,6 +35,7 @@ public class DecompilerDebugDumpHandler implements DebugDumpHandler { + public static boolean printToNowhere; private final PrintStream infoPrintStream = System.out; private File file; private FileOutputStream fos; @@ -55,6 +56,15 @@ filter = filter.substring(0, filter.indexOf("Phase")); } + if (printToNowhere) { + printStream = new PrintStream(new OutputStream() { + @Override + public void write(int b) throws IOException { + // DO NOTHING + } + }); + } + if (printStream == null) { fileName = "decompilerDump_" + uniqueId.incrementAndGet() + "_" + System.currentTimeMillis() + ".txt"; file = new File(fileName); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Mon Mar 17 14:30:59 2014 +0100 @@ -86,7 +86,7 @@ // This field must be lazily initialized as this class may be loaded in a version // VM startup phase at which not all required features (such as system properties) // are online. - private static SimpleDateFormat sdf; + private static volatile SimpleDateFormat sdf; private void initializeFilePrinter() { String ext; @@ -98,7 +98,13 @@ if (sdf == null) { sdf = new SimpleDateFormat("YYYY-MM-dd-HHmm"); } - String prefix = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date()); + + // DateFormats are inherently unsafe for multi-threaded use. Use a synchronized block. + String prefix; + synchronized (sdf) { + prefix = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date()); + } + String num = ""; File file; int i = 0; @@ -196,7 +202,7 @@ for (Object o : Debug.context()) { JavaMethod method = asJavaMethod(o); if (method != null) { - if (lastMethodOrGraph == null || asJavaMethod(lastMethodOrGraph) != method) { + if (lastMethodOrGraph == null || !asJavaMethod(lastMethodOrGraph).equals(method)) { result.add(MetaUtil.format("%H::%n(%p)", method)); } else { // This prevents multiple adjacent method context objects for the same method diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/NodeIntrinsicVerifier.java --- a/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/NodeIntrinsicVerifier.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.replacements.verifier/src/com/oracle/graal/replacements/verifier/NodeIntrinsicVerifier.java Mon Mar 17 14:30:59 2014 +0100 @@ -90,8 +90,12 @@ } if (isNodeType(nodeClass)) { - TypeMirror[] constructorSignature = constructorSignature(intrinsicMethod); - findConstructor(nodeClass, constructorSignature, intrinsicMethod, annotation); + if (nodeClass.getModifiers().contains(Modifier.ABSTRACT)) { + env.getMessager().printMessage(Kind.ERROR, String.format("Cannot make @NodeIntrinsic for abstract node class %s.", nodeClass.getSimpleName()), element, annotation); + } else { + TypeMirror[] constructorSignature = constructorSignature(intrinsicMethod); + findConstructor(nodeClass, constructorSignature, intrinsicMethod, annotation); + } } else { env.getMessager().printMessage(Kind.ERROR, String.format("The class %s is not a Node subclass.", nodeClass.getSimpleName()), element, annotation); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -452,7 +452,7 @@ for (MethodCallTargetNode callTarget : graph.getNodes(MethodCallTargetNode.class)) { ResolvedJavaMethod callee = callTarget.targetMethod(); - if (callee == recursiveEntry) { + if (callee.equals(recursiveEntry)) { if (isInlinableSnippet(substitutedMethod)) { final StructuredGraph originalGraph = buildInitialGraph(substitutedMethod); InliningUtil.inline(callTarget.invoke(), originalGraph, true); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Mon Mar 17 14:30:59 2014 +0100 @@ -340,7 +340,7 @@ return false; } CacheKey other = (CacheKey) obj; - if (method != other.method) { + if (!method.equals(other.method)) { return false; } if (guardsStage != other.guardsStage || loweringStage != other.loweringStage) { @@ -876,10 +876,11 @@ @Override public void replace(ValueNode oldNode, ValueNode newNode, MemoryMapNode mmap) { - if (mmap != null && newNode != null) { + if (mmap != null) { for (Node usage : oldNode.usages().snapshot()) { LocationIdentity identity = getLocationIdentity(usage); - if (identity != null && identity != LocationIdentity.FINAL_LOCATION) { + boolean usageReplaced = false; + if (identity != null && identity != FINAL_LOCATION) { // lastLocationAccess points into the snippet graph. find a proper // MemoryCheckPoint inside the snippet graph MemoryNode lastAccess = mmap.getLastLocationAccess(identity); @@ -888,17 +889,26 @@ if (usage instanceof MemoryAccess) { MemoryAccess access = (MemoryAccess) usage; if (access.getLastLocationAccess() == oldNode) { - assert newNode.graph().isAfterFloatingReadPhase(); + assert oldNode.graph().isAfterFloatingReadPhase(); access.setLastLocationAccess(lastAccess); + usageReplaced = true; } } else { assert usage instanceof MemoryProxy || usage instanceof MemoryPhiNode; usage.replaceFirstInput(oldNode, lastAccess.asNode()); + usageReplaced = true; } } + if (!usageReplaced) { + assert newNode != null : "this branch is only valid if we have a newNode for replacement"; + } } } - oldNode.replaceAtUsages(newNode); + if (newNode == null) { + assert oldNode.usages().isEmpty(); + } else { + oldNode.replaceAtUsages(newNode); + } } }; @@ -1002,12 +1012,6 @@ // Re-wire the control flow graph around the replacee FixedNode firstCFGNodeDuplicate = (FixedNode) duplicates.get(firstCFGNode); replacee.replaceAtPredecessor(firstCFGNodeDuplicate); - FixedNode next = null; - if (replacee instanceof FixedWithNextNode) { - FixedWithNextNode fwn = (FixedWithNextNode) replacee; - next = fwn.next(); - fwn.setNext(null); - } if (replacee instanceof StateSplit) { for (StateSplit sideEffectNode : sideEffectNodes) { @@ -1036,12 +1040,18 @@ returnValue = returnDuplicate.result(); MemoryMapNode mmap = new DuplicateMapper(duplicates, replaceeGraph.start()); if (returnValue == null && replacee.usages().isNotEmpty() && replacee instanceof MemoryCheckpoint) { - replacer.replace(replacee, (ValueNode) returnDuplicate.predecessor(), mmap); + replacer.replace(replacee, null, mmap); } else { assert returnValue != null || replacee.usages().isEmpty(); replacer.replace(replacee, returnValue, mmap); } if (returnDuplicate.isAlive()) { + FixedNode next = null; + if (replacee instanceof FixedWithNextNode) { + FixedWithNextNode fwn = (FixedWithNextNode) replacee; + next = fwn.next(); + fwn.setNext(null); + } returnDuplicate.clearInputs(); returnDuplicate.replaceAndDelete(next); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StringSubstitutions.java diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/MacroNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -169,7 +169,7 @@ protected void replaceSnippetInvokes(StructuredGraph snippetGraph) { for (MethodCallTargetNode call : snippetGraph.getNodes(MethodCallTargetNode.class)) { Invoke invoke = call.invoke(); - if (call.targetMethod() != getTargetMethod()) { + if (!call.targetMethod().equals(getTargetMethod())) { throw new GraalInternalError("unexpected invoke %s in snippet", getClass().getSimpleName()); } assert invoke.stateAfter().bci == FrameState.AFTER_BCI; diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.runtime/src/com/oracle/graal/runtime/RuntimeProvider.java --- a/graal/com.oracle.graal.runtime/src/com/oracle/graal/runtime/RuntimeProvider.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.runtime/src/com/oracle/graal/runtime/RuntimeProvider.java Mon Mar 17 14:30:59 2014 +0100 @@ -24,11 +24,9 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.compiler.target.*; -import com.oracle.graal.nodes.spi.*; /** - * A runtime supporting a host backend as well, zero or more additional backends and an optional - * {@linkplain GraphCache graph cache}. + * A runtime supporting a host backend as well, zero or more additional backends. */ public interface RuntimeProvider { @@ -43,9 +41,4 @@ * @param arch a specific architecture class */ Backend getBackend(Class arch); - - /** - * Gets the graph cache (if any) maintained by this runtime. - */ - GraphCache getGraphCache(); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARC.java --- a/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARC.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.sparc/src/com/oracle/graal/sparc/SPARC.java Mon Mar 17 14:30:59 2014 +0100 @@ -162,7 +162,6 @@ case Int: case Long: case Object: - case NarrowOop: return true; } } else if (category == FPU) { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Mon Mar 17 14:30:59 2014 +0100 @@ -203,8 +203,8 @@ CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod); - return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, - suites, true, new CompilationResult(), factory); + return compileGraph(graph, null, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, + suites, new CompilationResult(), factory); } private static Providers getGraalProviders() { diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Mon Mar 17 14:30:59 2014 +0100 @@ -43,6 +43,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind; import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.phases.*; @@ -50,7 +51,6 @@ import com.oracle.graal.phases.common.CanonicalizerPhase.CustomCanonicalizer; import com.oracle.graal.phases.tiers.*; import com.oracle.graal.phases.util.*; -import com.oracle.graal.runtime.*; import com.oracle.graal.truffle.nodes.asserts.*; import com.oracle.graal.truffle.nodes.frame.*; import com.oracle.graal.truffle.nodes.frame.NewFrameNode.VirtualOnlyInstanceNode; @@ -70,16 +70,16 @@ private final CanonicalizerPhase canonicalizer; private final GraphBuilderConfiguration config; private Set constantReceivers; - private final GraphCache cache; private final TruffleCache truffleCache; + private final ResolvedJavaType frameType; - public PartialEvaluator(RuntimeProvider runtime, Providers providers, TruffleCache truffleCache, GraphBuilderConfiguration config) { + public PartialEvaluator(Providers providers, TruffleCache truffleCache, GraphBuilderConfiguration config) { this.providers = providers; CustomCanonicalizer customCanonicalizer = new PartialEvaluatorCanonicalizer(providers.getMetaAccess(), providers.getConstantReflection()); this.canonicalizer = new CanonicalizerPhase(!ImmutableCode.getValue(), customCanonicalizer); this.config = config; - this.cache = runtime.getGraphCache(); this.truffleCache = truffleCache; + this.frameType = providers.getMetaAccess().lookupJavaType(FrameWithoutBoxing.class); try { executeHelperMethod = providers.getMetaAccess().lookupJavaMethod(OptimizedCallTarget.class.getDeclaredMethod("executeHelper", PackedFrame.class, Arguments.class)); } catch (NoSuchMethodException ex) { @@ -139,7 +139,11 @@ } canonicalizer.apply(graph, baseContext); - HighTierContext tierContext = new HighTierContext(providers, assumptions, cache, new PhaseSuite(), OptimisticOptimizations.NONE); + Map graphCache = null; + if (CacheGraphs.getValue()) { + graphCache = new HashMap<>(); + } + HighTierContext tierContext = new HighTierContext(providers, assumptions, graphCache, new PhaseSuite(), OptimisticOptimizations.NONE); for (NeverPartOfCompilationNode neverPartOfCompilationNode : graph.getNodes(NeverPartOfCompilationNode.class)) { Throwable exception = new VerificationError(neverPartOfCompilationNode.getMessage()); @@ -183,7 +187,7 @@ changed = false; for (MethodCallTargetNode methodCallTargetNode : graph.getNodes(MethodCallTargetNode.class)) { InvokeKind kind = methodCallTargetNode.invokeKind(); - if (kind == InvokeKind.Static || (kind == InvokeKind.Special && (methodCallTargetNode.receiver().isConstant() || methodCallTargetNode.receiver() instanceof NewFrameNode))) { + if (kind == InvokeKind.Static || (kind == InvokeKind.Special && (methodCallTargetNode.receiver().isConstant() || isFrame(methodCallTargetNode.receiver())))) { if (TraceTruffleCompilationHistogram.getValue() && kind == InvokeKind.Special) { ConstantNode constantNode = (ConstantNode) methodCallTargetNode.arguments().first(); constantReceivers.add(constantNode.asConstant()); @@ -237,6 +241,10 @@ } } + private boolean isFrame(ValueNode receiver) { + return receiver instanceof NewFrameNode || Objects.equals(ObjectStamp.typeOrNull(receiver.stamp()), frameType); + } + private StructuredGraph parseGraph(final ResolvedJavaMethod targetMethod, final NodeInputList arguments, final Assumptions assumptions, final PhaseContext phaseContext) { StructuredGraph graph = truffleCache.lookup(targetMethod, arguments, assumptions, canonicalizer); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCache.java Mon Mar 17 14:30:59 2014 +0100 @@ -247,6 +247,7 @@ private boolean shouldInline(final MethodCallTargetNode methodCallTargetNode) { return (methodCallTargetNode.invokeKind() == InvokeKind.Special || methodCallTargetNode.invokeKind() == InvokeKind.Static) && !Modifier.isNative(methodCallTargetNode.targetMethod().getModifiers()) && methodCallTargetNode.targetMethod().getAnnotation(ExplodeLoop.class) == null && - methodCallTargetNode.targetMethod().getAnnotation(CompilerDirectives.SlowPath.class) == null && methodCallTargetNode.targetMethod().getDeclaringClass() != stringBuilderClass; + methodCallTargetNode.targetMethod().getAnnotation(CompilerDirectives.SlowPath.class) == null && + !methodCallTargetNode.targetMethod().getDeclaringClass().equals(stringBuilderClass); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Mon Mar 17 14:30:59 2014 +0100 @@ -102,7 +102,7 @@ this.config = GraphBuilderConfiguration.getDefault(); this.config.setSkippedExceptionTypes(skippedExceptionTypes); - this.partialEvaluator = new PartialEvaluator(runtime, providers, truffleCache, config); + this.partialEvaluator = new PartialEvaluator(providers, truffleCache, config); if (Debug.isEnabled()) { DebugEnvironment.initialize(System.out); @@ -136,10 +136,6 @@ private InstalledCode compileMethodImpl(final OptimizedCallTarget compilable) { final StructuredGraph graph; - GraphCache graphCache = runtime.getGraphCache(); - if (graphCache != null) { - graphCache.removeStaleGraphs(); - } if (TraceTruffleCompilation.getValue()) { OptimizedCallTarget.logOptimizingStart(compilable); @@ -203,8 +199,8 @@ CodeCacheProvider codeCache = providers.getCodeCache(); CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); CompilationResult compilationResult = new CompilationResult(name); - result = compileGraph(graph, cc, graph.method(), providers, backend, codeCache.getTarget(), null, createGraphBuilderSuite(), Optimizations, getProfilingInfo(graph), speculationLog, - suites, false, compilationResult, CompilationResultBuilderFactory.Default); + result = compileGraph(graph, null, cc, graph.method(), providers, backend, codeCache.getTarget(), null, createGraphBuilderSuite(), Optimizations, getProfilingInfo(graph), speculationLog, + suites, compilationResult, CompilationResultBuilderFactory.Default); } catch (Throwable e) { throw Debug.handle(e); } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java Mon Mar 17 14:30:59 2014 +0100 @@ -59,7 +59,7 @@ @Override public boolean equals(Object obj) { - return obj.getClass() == getClass(); + return obj instanceof TruffleDebugJavaMethod; } @Override diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleExpansionLogger.java Mon Mar 17 14:30:59 2014 +0100 @@ -168,10 +168,10 @@ if (e.getLineNumber() >= 0) { return String.format("(%s:%d)", e.getFileName(), e.getLineNumber()); } else { - return String.format("(%s)", e.getFileName(), e.getLineNumber()); + return String.format("(%s)", e.getFileName()); } } else { - return String.format("(Unknown Source)", e.getFileName(), e.getLineNumber()); + return String.format("(Unknown Source)"); } } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationBlockState.java Mon Mar 17 14:30:59 2014 +0100 @@ -50,8 +50,11 @@ @Override public boolean equals(Object obj) { + if (!(obj instanceof ReadCacheEntry)) { + return false; + } ReadCacheEntry other = (ReadCacheEntry) obj; - return identity == other.identity && object == other.object; + return identity.equals(other.identity) && object == other.object; } @Override @@ -133,7 +136,7 @@ Iterator> iter = readCache.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); - if (entry.getKey().identity == identity) { + if (entry.getKey().identity.equals(identity)) { iter.remove(); } } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java Mon Mar 17 14:30:59 2014 +0100 @@ -162,7 +162,7 @@ } } if (phi) { - PhiNode phiNode = getCachedPhi(entry, value.kind()); + PhiNode phiNode = getCachedPhi(entry, value.stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCache"); for (int i = 0; i < states.size(); i++) { afterMergeEffects.addPhiInput(phiNode, states.get(i).getReadCache(key.object, key.identity, PEReadEliminationClosure.this)); @@ -194,7 +194,7 @@ values[i] = value; } - PhiNode phiNode = getCachedPhi(new ReadCacheEntry(identity, phi), values[0].kind()); + PhiNode phiNode = getCachedPhi(new ReadCacheEntry(identity, phi), values[0].stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCachePhi"); for (int i = 0; i < values.length; i++) { afterMergeEffects.addPhiInput(phiNode, values[i]); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java Mon Mar 17 14:30:59 2014 +0100 @@ -35,6 +35,7 @@ import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.spi.Virtualizable.EscapeState; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.virtual.*; import com.oracle.graal.phases.schedule.*; import com.oracle.graal.phases.util.*; @@ -284,10 +285,10 @@ super(mergeBlock); } - protected PhiNode getCachedPhi(T virtual, Kind kind) { + protected PhiNode getCachedPhi(T virtual, Stamp stamp) { PhiNode result = materializedPhis.get(virtual); if (result == null) { - result = new PhiNode(kind, merge); + result = new PhiNode(stamp, merge); materializedPhis.put(virtual, result); } return result; @@ -363,7 +364,7 @@ if (uniqueMaterializedValue != null) { newState.addObject(object, new ObjectState(object, uniqueMaterializedValue, EscapeState.Materialized, null)); } else { - PhiNode materializedValuePhi = getCachedPhi(object, Kind.Object); + PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object)); mergeEffects.addFloatingNode(materializedValuePhi, "materializedPhi"); for (int i = 0; i < objStates.length; i++) { ObjectState obj = objStates[i]; @@ -458,7 +459,7 @@ for (int i = 1; i < objStates.length; i++) { ValueNode[] fields = objStates[i].getEntries(); if (phis[valueIndex] == null && values[valueIndex] != fields[valueIndex]) { - phis[valueIndex] = new PhiNode(values[valueIndex].kind(), merge); + phis[valueIndex] = new PhiNode(values[valueIndex].stamp().unrestricted(), merge); } } if (twoSlotKinds != null && twoSlotKinds[valueIndex] != null) { @@ -487,7 +488,7 @@ return materialized; } else { // not compatible: materialize in all predecessors - PhiNode materializedValuePhi = getCachedPhi(object, Kind.Object); + PhiNode materializedValuePhi = getCachedPhi(object, StampFactory.forKind(Kind.Object)); for (int i = 0; i < blockStates.size(); i++) { ObjectState obj = objStates[i]; Block predecessor = mergeBlock.getPredecessors().get(i); @@ -579,7 +580,7 @@ for (int i = 0; i < objStates.length; i++) { ObjectState obj = objStates[i]; boolean hasIdentity = obj.virtual.hasIdentity() && mergedVirtualObjects.contains(obj.virtual); - if (hasIdentity || firstObj.virtual.type() != obj.virtual.type() || firstObj.virtual.entryCount() != obj.virtual.entryCount() || !firstObj.locksEqual(obj)) { + if (hasIdentity || !firstObj.virtual.type().equals(obj.virtual.type()) || firstObj.virtual.entryCount() != obj.virtual.entryCount() || !firstObj.locksEqual(obj)) { compatible = false; break; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationBlockState.java Mon Mar 17 14:30:59 2014 +0100 @@ -52,6 +52,9 @@ @Override public boolean equals(Object obj) { + if (!(obj instanceof CacheEntry)) { + return false; + } CacheEntry other = (CacheEntry) obj; return identity == other.identity && object == other.object; } diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/ReadEliminationClosure.java Mon Mar 17 14:30:59 2014 +0100 @@ -33,6 +33,7 @@ import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; +import com.oracle.graal.nodes.type.*; import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.schedule.*; import com.oracle.graal.virtual.phases.ea.ReadEliminationBlockState.CacheEntry; @@ -196,10 +197,10 @@ super(mergeBlock); } - protected PhiNode getCachedPhi(T virtual, Kind kind) { + protected PhiNode getCachedPhi(T virtual, Stamp stamp) { PhiNode result = materializedPhis.get(virtual); if (result == null) { - result = new PhiNode(kind, merge); + result = new PhiNode(stamp, merge); materializedPhis.put(virtual, result); } return result; @@ -229,7 +230,7 @@ } } if (phi) { - PhiNode phiNode = getCachedPhi(entry, value.kind()); + PhiNode phiNode = getCachedPhi(entry, value.stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCache"); for (int i = 0; i < states.size(); i++) { afterMergeEffects.addPhiInput(phiNode, states.get(i).getCacheEntry(key)); @@ -262,7 +263,7 @@ } CacheEntry newIdentifier = identifier.duplicateWithObject(phi); - PhiNode phiNode = getCachedPhi(newIdentifier, values[0].kind()); + PhiNode phiNode = getCachedPhi(newIdentifier, values[0].stamp().unrestricted()); mergeEffects.addFloatingNode(phiNode, "mergeReadCachePhi"); for (int i = 0; i < values.length; i++) { afterMergeEffects.addPhiInput(phiNode, values[i]); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/nodes/WordCastNode.java Mon Mar 17 14:30:59 2014 +0100 @@ -69,7 +69,7 @@ @Override public void generate(LIRGeneratorTool generator) { assert kind() != input.kind(); - assert generator.target().arch.getSizeInBytes(kind()) == generator.target().arch.getSizeInBytes(input.kind()); + assert generator.target().getSizeInBytes(kind()) == generator.target().getSizeInBytes(input.kind()); AllocatableValue result = generator.newVariable(kind()); generator.emitMove(result, generator.operand(input)); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/AbstractCodeWriter.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/AbstractCodeWriter.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/codewriter/AbstractCodeWriter.java Mon Mar 17 14:30:59 2014 +0100 @@ -267,11 +267,9 @@ if (parent.getKind() == ElementKind.ENUM && f.getModifiers().contains(Modifier.STATIC)) { write(f.getSimpleName()); if (init != null) { - if (init != null) { - write("("); - init.acceptCodeElementScanner(this, p); - write(")"); - } + write("("); + init.acceptCodeElementScanner(this, p); + write(")"); } } else { Element enclosing = f.getEnclosingElement(); diff -r 6681b9eb3f4c -r b1dded9c748a graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java --- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Mon Mar 17 14:29:45 2014 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Mon Mar 17 14:30:59 2014 +0100 @@ -222,7 +222,6 @@ } } ActualParameter sourceParameter = sourceMethod.findParameter(parameter.getLocalName()); - assert parameter != null; if (castedValues && sourceParameter != null) { builder.string(valueName(sourceParameter, parameter)); diff -r 6681b9eb3f4c -r b1dded9c748a graal/findbugsExcludeFilter.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/findbugsExcludeFilter.xml Mon Mar 17 14:30:59 2014 +0100 @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 6681b9eb3f4c -r b1dded9c748a hotspot/.cproject --- a/hotspot/.cproject Mon Mar 17 14:29:45 2014 +0100 +++ b/hotspot/.cproject Mon Mar 17 14:30:59 2014 +0100 @@ -44,6 +44,7 @@ +