Wed, 30 Jan 2013 12:26:45 +0100
8007062: Split Lower up into Lower/Attr/FinalizeTypes. Integrate AccessSpecalizer into FinalizeTypes.
Summary: Lower suffered from being a "God class" trying to do everything at once. As Nashorn code generation has grown, so has Lower. It does several post processing passes, tries to do several things at once even though all type information isn't in place, adjusting state afterwards and so on. It also performs control flow analysis, type attribution and constant folding, and everything else code generation related before byte code emission. I have now separated the compilation process into Lower (create low level nodes from high level ones, copy code such as finally block inlining etc), Attr (assign types and symbols to all nodes - freeze slot and scope information) and FinalizeTypes (insert explicit casts, specialize invoke dynamic types for scope accesses). I've removed the kludgy AccessSpecializer, as this now integrates naturally with typing. Everything is now much easier to read and each module performs only one thing. I have added separate loggers for the separate tiers. In the process I have also fixed: (1) problems with type coercion (see test/script/basic/typecoercion.js, basically our coercion was too late and our symbol inference was erroneous. This only manifested itself in very rare occasions where toNumber coercion has side effects, such as for example when valueOf is overridden) (2) copying literal nodes (literal copy did not use the superclass copy, which made all the Node specific fields not to be copied (3) erroneous literal tokenization (literals shouldn't always just inherit token information from whatever node that creates them) (4) splitter weighnodes - unary nodes were considered weightless (4) removed the hateful and kludgy "VarNode.shouldAppend", which really isn't needed when we have an attribution phase that determines self reference symbols (the only thing it was used for) (5) duplicate line number issues in the parser (6) convert bug in CodeGenerator for intermediate results of scope accesses (see test/script/basic/access-specializer.js) ... Several of these things just stopped being problems with the new architecture "can't happen anymore" and are not bug fixes per se. All tests run. No performance regressions exist that I've been able to measure. Some increases in performance were measured, but in the statistical margin of error (which is very wide as HotSpot currently has warmup issues with LambdaForms/invoke dynamic). Compile speed has not measurably increased.
Reviewed-by: jlaskey, attila
jlaskey@3 | 1 | DO NOT TRANSLATE OR LOCALIZE. |
jlaskey@3 | 2 | ----------------------------- |
jlaskey@3 | 3 | |
jlaskey@3 | 4 | %% This notice is provided with respect to ECMAScript Language |
jlaskey@3 | 5 | Specification ECMA-262 Edition 5.1 which is included with the Nashorn |
jlaskey@3 | 6 | technology. |
jlaskey@3 | 7 | |
jlaskey@3 | 8 | --- begin of LICENSE --- |
jlaskey@3 | 9 | Copyright notice |
jlaskey@3 | 10 | Copyright © 2011 Ecma International |
jlaskey@3 | 11 | Ecma International |
jlaskey@3 | 12 | Rue du Rhone 114 |
jlaskey@3 | 13 | CH-1204 Geneva |
jlaskey@3 | 14 | Tel: +41 22 849 6000 |
jlaskey@3 | 15 | Fax: +41 22 849 6001 |
jlaskey@3 | 16 | Web: http://www.ecma-international.org |
jlaskey@3 | 17 | |
jlaskey@3 | 18 | This document and possible translations of it may be copied and furnished to |
jlaskey@3 | 19 | others, and derivative works that comment on or otherwise explain it or assist |
jlaskey@3 | 20 | in its implementation may be prepared, copied, published, and distributed, in |
jlaskey@3 | 21 | whole or in part, without restriction of any kind, provided that the above |
jlaskey@3 | 22 | copyright notice and this section are included on all such copies and derivative |
jlaskey@3 | 23 | works. However, this document itself may not be modified in any way, including |
jlaskey@3 | 24 | by removing the copyright notice or references to Ecma International, except as |
jlaskey@3 | 25 | needed for the purpose of developing any document or deliverable produced by |
jlaskey@3 | 26 | Ecma International (in which case the rules applied to copyrights must be |
jlaskey@3 | 27 | followed) or as required to translate it into languages other than English. The |
jlaskey@3 | 28 | limited permissions granted above are perpetual and will not be revoked by Ecma |
jlaskey@3 | 29 | International or its successors or assigns. This document and the information |
jlaskey@3 | 30 | contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL |
jlaskey@3 | 31 | DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY |
jlaskey@3 | 32 | WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP |
jlaskey@3 | 33 | RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR |
jlaskey@3 | 34 | PURPOSE." Software License |
jlaskey@3 | 35 | |
jlaskey@3 | 36 | All Software contained in this document ("Software)" is protected by copyright |
jlaskey@3 | 37 | and is being made available under the "BSD License", included below. This |
jlaskey@3 | 38 | Software may be subject to third party rights (rights from parties other than |
jlaskey@3 | 39 | Ecma International), including patent rights, and no licenses under such third |
jlaskey@3 | 40 | party rights are granted under this license even if the third party concerned is |
jlaskey@3 | 41 | a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS |
jlaskey@3 | 42 | AVAILABLE AT http://www.ecma-international.org/memento/codeofconduct.htm FOR |
jlaskey@3 | 43 | INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO |
jlaskey@3 | 44 | IMPLEMENT ECMA INTERNATIONAL STANDARDS*. Redistribution and use in source and |
jlaskey@3 | 45 | binary forms, with or without modification, are permitted provided that the |
jlaskey@3 | 46 | following conditions are met: |
jlaskey@3 | 47 | |
jlaskey@3 | 48 | 1. Redistributions of source code must retain the above copyright notice, this |
jlaskey@3 | 49 | list of conditions and the following disclaimer. |
jlaskey@3 | 50 | |
jlaskey@3 | 51 | 2. Redistributions in binary form must reproduce the above copyright notice, |
jlaskey@3 | 52 | this list of conditions and the following disclaimer in the documentation and/or |
jlaskey@3 | 53 | other materials provided with the distribution. |
jlaskey@3 | 54 | |
jlaskey@3 | 55 | 3. Neither the name of the authors nor Ecma International may be used to endorse |
jlaskey@3 | 56 | or promote products derived from this software without specific prior written |
jlaskey@3 | 57 | permission. |
jlaskey@3 | 58 | |
jlaskey@3 | 59 | THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR |
jlaskey@3 | 60 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
jlaskey@3 | 61 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
jlaskey@3 | 62 | SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
jlaskey@3 | 63 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
jlaskey@3 | 64 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
jlaskey@3 | 65 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
jlaskey@3 | 66 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
jlaskey@3 | 67 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
jlaskey@3 | 68 | OF SUCH DAMAGE. |
jlaskey@3 | 69 | --- end of LICENSE --- |