| 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart'; | 7 import 'package:js_runtime/shared/embedded_names.dart'; |
| 8 | 8 |
| 9 import '../closure.dart'; | 9 import '../closure.dart'; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 * or inlined by this builder. | 410 * or inlined by this builder. |
| 411 */ | 411 */ |
| 412 final List<Element> sourceElementStack = <Element>[]; | 412 final List<Element> sourceElementStack = <Element>[]; |
| 413 | 413 |
| 414 LocalsHandler localsHandler; | 414 LocalsHandler localsHandler; |
| 415 | 415 |
| 416 HInstruction rethrowableException; | 416 HInstruction rethrowableException; |
| 417 | 417 |
| 418 Map<JumpTarget, JumpHandler> jumpTargets = <JumpTarget, JumpHandler>{}; | 418 Map<JumpTarget, JumpHandler> jumpTargets = <JumpTarget, JumpHandler>{}; |
| 419 | 419 |
| 420 // We build the Ssa graph by simulating a stack machine. | |
| 421 List<HInstruction> stack = <HInstruction>[]; | |
| 422 | |
| 423 /// Returns `true` if the current element is an `async` function. | 420 /// Returns `true` if the current element is an `async` function. |
| 424 bool get isBuildingAsyncFunction { | 421 bool get isBuildingAsyncFunction { |
| 425 Element element = sourceElement; | 422 Element element = sourceElement; |
| 426 return (element is FunctionElement && | 423 return (element is FunctionElement && |
| 427 element.asyncMarker == AsyncMarker.ASYNC); | 424 element.asyncMarker == AsyncMarker.ASYNC); |
| 428 } | 425 } |
| 429 | 426 |
| 430 // TODO(sigmund): make most args optional | 427 // TODO(sigmund): make most args optional |
| 431 SsaBuilder( | 428 SsaBuilder( |
| 432 this.target, | 429 this.target, |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 add(assertIsSubtype); | 1896 add(assertIsSubtype); |
| 1900 } | 1897 } |
| 1901 | 1898 |
| 1902 HGraph closeFunction() { | 1899 HGraph closeFunction() { |
| 1903 // TODO(kasperl): Make this goto an implicit return. | 1900 // TODO(kasperl): Make this goto an implicit return. |
| 1904 if (!isAborted()) closeAndGotoExit(new HGoto()); | 1901 if (!isAborted()) closeAndGotoExit(new HGoto()); |
| 1905 graph.finalize(); | 1902 graph.finalize(); |
| 1906 return graph; | 1903 return graph; |
| 1907 } | 1904 } |
| 1908 | 1905 |
| 1909 void push(HInstruction instruction) { | |
| 1910 add(instruction); | |
| 1911 stack.add(instruction); | |
| 1912 } | |
| 1913 | |
| 1914 void pushWithPosition(HInstruction instruction, ast.Node node) { | 1906 void pushWithPosition(HInstruction instruction, ast.Node node) { |
| 1915 push(attachPosition(instruction, node)); | 1907 push(attachPosition(instruction, node)); |
| 1916 } | 1908 } |
| 1917 | 1909 |
| 1918 HInstruction pop() { | |
| 1919 return stack.removeLast(); | |
| 1920 } | |
| 1921 | |
| 1922 void dup() { | |
| 1923 stack.add(stack.last); | |
| 1924 } | |
| 1925 | |
| 1926 HInstruction popBoolified() { | 1910 HInstruction popBoolified() { |
| 1927 HInstruction value = pop(); | 1911 HInstruction value = pop(); |
| 1928 if (_checkOrTrustTypes) { | 1912 if (_checkOrTrustTypes) { |
| 1929 return potentiallyCheckOrTrustType(value, compiler.coreTypes.boolType, | 1913 return potentiallyCheckOrTrustType(value, compiler.coreTypes.boolType, |
| 1930 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); | 1914 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); |
| 1931 } | 1915 } |
| 1932 HInstruction result = new HBoolify(value, backend.boolType); | 1916 HInstruction result = new HBoolify(value, backend.boolType); |
| 1933 add(result); | 1917 add(result); |
| 1934 return result; | 1918 return result; |
| 1935 } | 1919 } |
| (...skipping 5902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7838 const _LoopTypeVisitor(); | 7822 const _LoopTypeVisitor(); |
| 7839 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | 7823 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; |
| 7840 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | 7824 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; |
| 7841 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | 7825 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; |
| 7842 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 7826 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
| 7843 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7827 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 7844 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 7828 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 7845 int visitSwitchStatement(ast.SwitchStatement node) => | 7829 int visitSwitchStatement(ast.SwitchStatement node) => |
| 7846 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 7830 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
| 7847 } | 7831 } |
| OLD | NEW |