| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 | 6 |
| 7 final JavaScriptBackend backend; | 7 final JavaScriptBackend backend; |
| 8 | 8 |
| 9 SsaCodeGeneratorTask(JavaScriptBackend backend) | 9 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 10 : this.backend = backend, | 10 : this.backend = backend, |
| (...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 | 1909 |
| 1910 visitThrow(HThrow node) { | 1910 visitThrow(HThrow node) { |
| 1911 if (node.isRethrow) { | 1911 if (node.isRethrow) { |
| 1912 use(node.inputs[0]); | 1912 use(node.inputs[0]); |
| 1913 pushStatement(new js.Throw(pop()), node); | 1913 pushStatement(new js.Throw(pop()), node); |
| 1914 } else { | 1914 } else { |
| 1915 generateThrowWithHelper(r'$throw', node.inputs[0]); | 1915 generateThrowWithHelper(r'$throw', node.inputs[0]); |
| 1916 } | 1916 } |
| 1917 } | 1917 } |
| 1918 | 1918 |
| 1919 visitRangeConversion(HRangeConversion node) { |
| 1920 // Range conversion instructions are removed by the value range |
| 1921 // analyzer. |
| 1922 assert(false); |
| 1923 } |
| 1924 |
| 1919 visitBoundsCheck(HBoundsCheck node) { | 1925 visitBoundsCheck(HBoundsCheck node) { |
| 1920 // TODO(ngeoffray): Separate the two checks of the bounds check, so, | 1926 // TODO(ngeoffray): Separate the two checks of the bounds check, so, |
| 1921 // e.g., the zero checks can be shared if possible. | 1927 // e.g., the zero checks can be shared if possible. |
| 1922 | 1928 |
| 1923 // If the checks always succeeds, we would have removed the bounds check | 1929 // If the checks always succeeds, we would have removed the bounds check |
| 1924 // completely. | 1930 // completely. |
| 1925 assert(node.staticChecks != HBoundsCheck.ALWAYS_TRUE); | 1931 assert(node.staticChecks != HBoundsCheck.ALWAYS_TRUE); |
| 1926 if (node.staticChecks != HBoundsCheck.ALWAYS_FALSE) { | 1932 if (node.staticChecks != HBoundsCheck.ALWAYS_FALSE) { |
| 1927 js.Binary under; | 1933 js.Expression under; |
| 1934 js.Expression over; |
| 1928 if (node.staticChecks != HBoundsCheck.ALWAYS_ABOVE_ZERO) { | 1935 if (node.staticChecks != HBoundsCheck.ALWAYS_ABOVE_ZERO) { |
| 1929 assert(node.staticChecks == HBoundsCheck.FULL_CHECK); | |
| 1930 use(node.index); | 1936 use(node.index); |
| 1931 under = new js.Binary("<", pop(), new js.LiteralNumber("0")); | 1937 under = new js.Binary("<", pop(), new js.LiteralNumber("0")); |
| 1932 } | 1938 } |
| 1933 use(node.index); | 1939 if (node.staticChecks != HBoundsCheck.ALWAYS_BELOW_LENGTH) { |
| 1934 js.Expression index = pop(); | 1940 var index = node.index; |
| 1935 use(node.length); | 1941 use(index); |
| 1936 js.Binary over = new js.Binary(">=", index, pop()); | 1942 js.Expression jsIndex = pop(); |
| 1937 js.Binary underOver = | 1943 use(node.length); |
| 1938 under == null ? over : new js.Binary("||", under, over); | 1944 over = new js.Binary(">=", jsIndex, pop()); |
| 1945 } |
| 1946 assert(over != null || under != null); |
| 1947 js.Expression underOver = under == null |
| 1948 ? over |
| 1949 : over == null |
| 1950 ? under |
| 1951 : new js.Binary("||", under, over); |
| 1939 js.Statement thenBody = new js.Block.empty(); | 1952 js.Statement thenBody = new js.Block.empty(); |
| 1940 js.Block oldContainer = currentContainer; | 1953 js.Block oldContainer = currentContainer; |
| 1941 currentContainer = thenBody; | 1954 currentContainer = thenBody; |
| 1942 generateThrowWithHelper('ioore', node.index); | 1955 generateThrowWithHelper('ioore', node.index); |
| 1943 currentContainer = oldContainer; | 1956 currentContainer = oldContainer; |
| 1944 thenBody = unwrapStatement(thenBody); | 1957 thenBody = unwrapStatement(thenBody); |
| 1945 pushStatement(new js.If.noElse(underOver, thenBody), node); | 1958 pushStatement(new js.If.noElse(underOver, thenBody), node); |
| 1946 } else { | 1959 } else { |
| 1947 generateThrowWithHelper('ioore', node.index); | 1960 generateThrowWithHelper('ioore', node.index); |
| 1948 } | 1961 } |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2995 if (leftType.canBeNull() && rightType.canBeNull()) { | 3008 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2996 if (left.isConstantNull() || right.isConstantNull() || | 3009 if (left.isConstantNull() || right.isConstantNull() || |
| 2997 (leftType.isPrimitive() && leftType == rightType)) { | 3010 (leftType.isPrimitive() && leftType == rightType)) { |
| 2998 return '=='; | 3011 return '=='; |
| 2999 } | 3012 } |
| 3000 return null; | 3013 return null; |
| 3001 } else { | 3014 } else { |
| 3002 return '==='; | 3015 return '==='; |
| 3003 } | 3016 } |
| 3004 } | 3017 } |
| OLD | NEW |