Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 57773002: Repro for OOM bug in test.dart (applies to r29345). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 HInstruction representations = buildTypeArgumentRepresentations(type); 1878 HInstruction representations = buildTypeArgumentRepresentations(type);
1879 add(representations); 1879 add(representations);
1880 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, 1880 return new HTypeConversion.withTypeRepresentation(type, kind, subtype,
1881 original, representations); 1881 original, representations);
1882 } else if (type.kind == TypeKind.TYPE_VARIABLE) { 1882 } else if (type.kind == TypeKind.TYPE_VARIABLE) {
1883 HType subtype = original.instructionType; 1883 HType subtype = original.instructionType;
1884 HInstruction typeVariable = addTypeVariableReference(type); 1884 HInstruction typeVariable = addTypeVariableReference(type);
1885 return new HTypeConversion.withTypeRepresentation(type, kind, subtype, 1885 return new HTypeConversion.withTypeRepresentation(type, kind, subtype,
1886 original, typeVariable); 1886 original, typeVariable);
1887 } else if (type.kind == TypeKind.FUNCTION) { 1887 } else if (type.kind == TypeKind.FUNCTION) {
1888 // HERE
1889 String name = kind == HTypeConversion.CAST_TYPE_CHECK
1890 ? '_asCheck' : '_assertCheck';
1891
1892 List arguments = [buildFunctionType(type), original];
1893 pushInvokeDynamic(
1894 null,
1895 new Selector.call(name, compiler.jsHelperLibrary, 1),
1896 arguments);
1897
1898 return new HTypeConversion(type, kind, original.instructionType, pop());
1899 /*
1900
1888 if (backend.rti.isSimpleFunctionType(type)) { 1901 if (backend.rti.isSimpleFunctionType(type)) {
1889 return original.convertType(compiler, type, kind); 1902 return original.convertType(compiler, type, kind);
1890 } 1903 }
1891 HType subtype = original.instructionType; 1904 HType subtype = original.instructionType;
1892 if (type.containsTypeVariables) { 1905 if (type.containsTypeVariables) {
1893 bool contextIsTypeArguments = false; 1906 bool contextIsTypeArguments = false;
1894 HInstruction context; 1907 HInstruction context;
1895 if (!currentElement.enclosingElement.isClosure() 1908 if (!currentElement.enclosingElement.isClosure()
1896 && currentElement.isInstanceMember()) { 1909 && currentElement.isInstanceMember()) {
1897 context = localsHandler.readThis(); 1910 context = localsHandler.readThis();
1898 } else { 1911 } else {
1899 ClassElement contextClass = Types.getClassContext(type); 1912 ClassElement contextClass = Types.getClassContext(type);
1900 context = buildTypeVariableList(contextClass); 1913 context = buildTypeVariableList(contextClass);
1901 add(context); 1914 add(context);
1902 contextIsTypeArguments = true; 1915 contextIsTypeArguments = true;
1903 } 1916 }
1904 return new HTypeConversion.withContext(type, kind, subtype, 1917 return new HTypeConversion.withContext(type, kind, subtype,
1905 original, context, contextIsTypeArguments: contextIsTypeArguments); 1918 original, context, contextIsTypeArguments: contextIsTypeArguments);
1906 } else { 1919 } else {
1907 return new HTypeConversion(type, kind, subtype, original); 1920 return new HTypeConversion(type, kind, subtype, original);
1908 } 1921 }
1922 */
1909 } else { 1923 } else {
1910 return original.convertType(compiler, type, kind); 1924 return original.convertType(compiler, type, kind);
1911 } 1925 }
1912 } 1926 }
1913 1927
1914 HInstruction potentiallyCheckType(HInstruction original, DartType type, 1928 HInstruction potentiallyCheckType(HInstruction original, DartType type,
1915 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) { 1929 { int kind: HTypeConversion.CHECKED_MODE_CHECK }) {
1916 if (!compiler.enableTypeAssertions) return original; 1930 if (!compiler.enableTypeAssertions) return original;
1917 HInstruction other = buildTypeConversion(original, type, kind); 1931 HInstruction other = buildTypeConversion(original, type, kind);
1918 if (other != original) add(other); 1932 if (other != original) add(other);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 value, 2021 value,
2008 compiler.boolClass.computeType(compiler), 2022 compiler.boolClass.computeType(compiler),
2009 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); 2023 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK);
2010 } 2024 }
2011 HInstruction result = new HBoolify(value); 2025 HInstruction result = new HBoolify(value);
2012 add(result); 2026 add(result);
2013 return result; 2027 return result;
2014 } 2028 }
2015 2029
2016 HInstruction attachPosition(HInstruction target, Node node) { 2030 HInstruction attachPosition(HInstruction target, Node node) {
2017 target.sourcePosition = sourceFileLocationForBeginToken(node); 2031 if (node != null) {
2032 target.sourcePosition = sourceFileLocationForBeginToken(node);
2033 }
2018 return target; 2034 return target;
2019 } 2035 }
2020 2036
2021 SourceFileLocation sourceFileLocationForBeginToken(Node node) => 2037 SourceFileLocation sourceFileLocationForBeginToken(Node node) =>
2022 sourceFileLocationForToken(node, node.getBeginToken()); 2038 sourceFileLocationForToken(node, node.getBeginToken());
2023 2039
2024 SourceFileLocation sourceFileLocationForEndToken(Node node) => 2040 SourceFileLocation sourceFileLocationForEndToken(Node node) =>
2025 sourceFileLocationForToken(node, node.getEndToken()); 2041 sourceFileLocationForToken(node, node.getEndToken());
2026 2042
2027 SourceFileLocation sourceFileLocationForToken(Node node, Token token) { 2043 SourceFileLocation sourceFileLocationForToken(Node node, Token token) {
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
2909 HLiteralList buildTypeVariableList(ClassElement contextClass) { 2925 HLiteralList buildTypeVariableList(ClassElement contextClass) {
2910 List<HInstruction> inputs = <HInstruction>[]; 2926 List<HInstruction> inputs = <HInstruction>[];
2911 for (Link<DartType> link = contextClass.typeVariables; 2927 for (Link<DartType> link = contextClass.typeVariables;
2912 !link.isEmpty; 2928 !link.isEmpty;
2913 link = link.tail) { 2929 link = link.tail) {
2914 inputs.add(addTypeVariableReference(link.head)); 2930 inputs.add(addTypeVariableReference(link.head));
2915 } 2931 }
2916 return buildLiteralList(inputs); 2932 return buildLiteralList(inputs);
2917 } 2933 }
2918 2934
2935 HInstruction buildFunctionType(FunctionType type) {
2936 List<HInstruction> typeVariables = <HInstruction>[];
2937 bool hasDirectTypeVariables =
2938 !currentElement.enclosingElement.isClosure() &&
2939 currentElement.isInstanceMember();
2940
2941 type.forEachTypeVariable((TypeVariableType variable) {
2942 if (hasDirectTypeVariables) {
2943 HInstruction receiver = localsHandler.readThis();
2944 push(new HReadTypeVariable(variable, receiver));
2945 } else {
2946 push(
2947 new HReadTypeVariable.noReceiver(
2948 variable, addTypeVariableReference(variable)));
2949 }
2950 typeVariables.add(pop());
2951 });
2952 push(new HFunctionType(typeVariables, type));
2953 return pop();
2954 }
2955
2919 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) { 2956 HInstruction buildIsNode(Node node, DartType type, HInstruction expression) {
2920 type = type.unalias(compiler); 2957 type = type.unalias(compiler);
2921 if (type.kind == TypeKind.FUNCTION) { 2958 if (type.kind == TypeKind.FUNCTION) {
2959 // HERE
2960 List arguments = [buildFunctionType(type), expression];
2961 pushInvokeDynamic(
2962 node, new Selector.call('_isTest', compiler.jsHelperLibrary, 1),
2963 arguments);
2964
2965 return new HIs.compound(type, expression, pop());
2966
2967 /*
2922 if (backend.rti.isSimpleFunctionType(type)) { 2968 if (backend.rti.isSimpleFunctionType(type)) {
2923 // TODO(johnniwinther): Avoid interceptor if unneeded. 2969 // TODO(johnniwinther): Avoid interceptor if unneeded.
2924 return new HIs.raw(type, expression, invokeInterceptor(expression)); 2970 return new HIs.raw(type, expression, invokeInterceptor(expression));
2925 } 2971 }
2926 Element checkFunctionSubtype = backend.getCheckFunctionSubtype(); 2972 Element checkFunctionSubtype = backend.getCheckFunctionSubtype();
2927 2973
2928 HInstruction signatureName = graph.addConstantString( 2974 HInstruction signatureName = graph.addConstantString(
2929 new DartString.literal(backend.namer.getFunctionTypeName(type)), 2975 new DartString.literal(backend.namer.getFunctionTypeName(type)),
2930 node, compiler); 2976 node, compiler);
2931 2977
(...skipping 21 matching lines...) Expand all
2953 } 2999 }
2954 3000
2955 List<HInstruction> inputs = <HInstruction>[expression, 3001 List<HInstruction> inputs = <HInstruction>[expression,
2956 signatureName, 3002 signatureName,
2957 contextName, 3003 contextName,
2958 context, 3004 context,
2959 typeArguments]; 3005 typeArguments];
2960 pushInvokeStatic(node, checkFunctionSubtype, inputs, HType.BOOLEAN); 3006 pushInvokeStatic(node, checkFunctionSubtype, inputs, HType.BOOLEAN);
2961 HInstruction call = pop(); 3007 HInstruction call = pop();
2962 return new HIs.compound(type, expression, call); 3008 return new HIs.compound(type, expression, call);
3009 */
2963 } else if (type.kind == TypeKind.TYPE_VARIABLE) { 3010 } else if (type.kind == TypeKind.TYPE_VARIABLE) {
2964 HInstruction runtimeType = addTypeVariableReference(type); 3011 HInstruction runtimeType = addTypeVariableReference(type);
2965 Element helper = backend.getCheckSubtypeOfRuntimeType(); 3012 Element helper = backend.getCheckSubtypeOfRuntimeType();
2966 List<HInstruction> inputs = <HInstruction>[expression, runtimeType]; 3013 List<HInstruction> inputs = <HInstruction>[expression, runtimeType];
2967 pushInvokeStatic(null, helper, inputs, HType.BOOLEAN); 3014 pushInvokeStatic(null, helper, inputs, HType.BOOLEAN);
2968 HInstruction call = pop(); 3015 HInstruction call = pop();
2969 return new HIs.variable(type, expression, call); 3016 return new HIs.variable(type, expression, call);
2970 } else if (RuntimeTypes.hasTypeArguments(type)) { 3017 } else if (RuntimeTypes.hasTypeArguments(type)) {
2971 ClassElement element = type.element; 3018 ClassElement element = type.element;
2972 Element helper = backend.getCheckSubtype(); 3019 Element helper = backend.getCheckSubtype();
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 new HSubGraphBlockInformation(elseBranch.graph)); 5635 new HSubGraphBlockInformation(elseBranch.graph));
5589 5636
5590 HBasicBlock conditionStartBlock = conditionBranch.block; 5637 HBasicBlock conditionStartBlock = conditionBranch.block;
5591 conditionStartBlock.setBlockFlow(info, joinBlock); 5638 conditionStartBlock.setBlockFlow(info, joinBlock);
5592 SubGraph conditionGraph = conditionBranch.graph; 5639 SubGraph conditionGraph = conditionBranch.graph;
5593 HIf branch = conditionGraph.end.last; 5640 HIf branch = conditionGraph.end.last;
5594 assert(branch is HIf); 5641 assert(branch is HIf);
5595 branch.blockInformation = conditionStartBlock.blockFlow; 5642 branch.blockInformation = conditionStartBlock.blockFlow;
5596 } 5643 }
5597 } 5644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698