Chromium Code Reviews| 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. |
|
Søren Gjesse
2012/09/26 09:08:24
Maybe add a visitRangeConversion which asserts fal
ngeoffray
2012/09/26 09:33:26
Done.
| |
| 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, |
| 11 super(backend.compiler); | 11 super(backend.compiler); |
| 12 String get name => 'SSA code generator'; | 12 String get name => 'SSA code generator'; |
| 13 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; | 13 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; |
| (...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 visitBoundsCheck(HBoundsCheck node) { | 1918 visitBoundsCheck(HBoundsCheck node) { |
| 1919 // TODO(ngeoffray): Separate the two checks of the bounds check, so, | 1919 // TODO(ngeoffray): Separate the two checks of the bounds check, so, |
| 1920 // e.g., the zero checks can be shared if possible. | 1920 // e.g., the zero checks can be shared if possible. |
| 1921 | 1921 |
| 1922 // If the checks always succeeds, we would have removed the bounds check | 1922 // If the checks always succeeds, we would have removed the bounds check |
| 1923 // completely. | 1923 // completely. |
| 1924 assert(node.staticChecks != HBoundsCheck.ALWAYS_TRUE); | 1924 assert(node.staticChecks != HBoundsCheck.ALWAYS_TRUE); |
| 1925 if (node.staticChecks != HBoundsCheck.ALWAYS_FALSE) { | 1925 if (node.staticChecks != HBoundsCheck.ALWAYS_FALSE) { |
| 1926 js.Binary under; | 1926 js.Expression under; |
| 1927 js.Expression over; | |
| 1927 if (node.staticChecks != HBoundsCheck.ALWAYS_ABOVE_ZERO) { | 1928 if (node.staticChecks != HBoundsCheck.ALWAYS_ABOVE_ZERO) { |
| 1928 assert(node.staticChecks == HBoundsCheck.FULL_CHECK); | |
| 1929 use(node.index); | 1929 use(node.index); |
| 1930 under = new js.Binary("<", pop(), new js.LiteralNumber("0")); | 1930 under = new js.Binary("<", pop(), new js.LiteralNumber("0")); |
| 1931 } | 1931 } |
| 1932 use(node.index); | 1932 if (node.staticChecks != HBoundsCheck.ALWAYS_BELOW_LENGTH) { |
| 1933 js.Expression index = pop(); | 1933 var index = node.index; |
| 1934 use(node.length); | 1934 use(index); |
| 1935 js.Binary over = new js.Binary(">=", index, pop()); | 1935 js.Expression jsIndex = pop(); |
| 1936 js.Binary underOver = | 1936 use(node.length); |
| 1937 under == null ? over : new js.Binary("||", under, over); | 1937 over = new js.Binary(">=", jsIndex, pop()); |
| 1938 } | |
| 1939 js.Expression underOver = under == null | |
| 1940 ? over | |
| 1941 : over == null | |
| 1942 ? under | |
| 1943 : new js.Binary("||", under, over); | |
| 1938 js.Statement thenBody = new js.Block.empty(); | 1944 js.Statement thenBody = new js.Block.empty(); |
| 1939 js.Block oldContainer = currentContainer; | 1945 js.Block oldContainer = currentContainer; |
| 1940 currentContainer = thenBody; | 1946 currentContainer = thenBody; |
| 1941 generateThrowWithHelper('ioore', node.index); | 1947 generateThrowWithHelper('ioore', node.index); |
| 1942 currentContainer = oldContainer; | 1948 currentContainer = oldContainer; |
| 1943 thenBody = unwrapStatement(thenBody); | 1949 thenBody = unwrapStatement(thenBody); |
| 1944 pushStatement(new js.If.noElse(underOver, thenBody), node); | 1950 pushStatement(new js.If.noElse(underOver, thenBody), node); |
| 1945 } else { | 1951 } else { |
| 1946 generateThrowWithHelper('ioore', node.index); | 1952 generateThrowWithHelper('ioore', node.index); |
| 1947 } | 1953 } |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2994 if (leftType.canBeNull() && rightType.canBeNull()) { | 3000 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2995 if (left.isConstantNull() || right.isConstantNull() || | 3001 if (left.isConstantNull() || right.isConstantNull() || |
| 2996 (leftType.isPrimitive() && leftType == rightType)) { | 3002 (leftType.isPrimitive() && leftType == rightType)) { |
| 2997 return '=='; | 3003 return '=='; |
| 2998 } | 3004 } |
| 2999 return null; | 3005 return null; |
| 3000 } else { | 3006 } else { |
| 3001 return '==='; | 3007 return '==='; |
| 3002 } | 3008 } |
| 3003 } | 3009 } |
| OLD | NEW |