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

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

Issue 98643009: Short curcuit the inlining when code in the middle of an expression is aborting. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/from_ir_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 && (selector.mask == null || selector.mask.isNullable)) { 1310 && (selector.mask == null || selector.mask.isNullable)) {
1311 addWithPosition( 1311 addWithPosition(
1312 new HFieldGet(null, providedArguments[0], backend.dynamicType, 1312 new HFieldGet(null, providedArguments[0], backend.dynamicType,
1313 isAssignable: false), 1313 isAssignable: false),
1314 currentNode); 1314 currentNode);
1315 } 1315 }
1316 List<HInstruction> compiledArguments = completeSendArgumentsList( 1316 List<HInstruction> compiledArguments = completeSendArgumentsList(
1317 function, selector, providedArguments, currentNode); 1317 function, selector, providedArguments, currentNode);
1318 enterInlinedMethod(function, currentNode, compiledArguments); 1318 enterInlinedMethod(function, currentNode, compiledArguments);
1319 inlinedFrom(function, () { 1319 inlinedFrom(function, () {
1320 doInline(function); 1320 if (!isReachable) {
1321 emitReturn(graph.addConstantNull(compiler), null);
1322 } else {
1323 doInline(function);
1324 }
1321 }); 1325 });
1322 leaveInlinedMethod(); 1326 leaveInlinedMethod();
1323 } 1327 }
1324 1328
1325 if (meetsHardConstraints() && heuristicSayGoodToGo()) { 1329 if (meetsHardConstraints() && heuristicSayGoodToGo()) {
1326 doInlining(); 1330 doInlining();
1327 return true; 1331 return true;
1328 } 1332 }
1329 1333
1330 return false; 1334 return false;
1331 } 1335 }
1332 1336
1337 void emitReturn(HInstruction value, N node);
1338
1333 void doInline(FunctionElement function); 1339 void doInline(FunctionElement function);
1334 1340
1335 inlinedFrom(Element element, f()) { 1341 inlinedFrom(Element element, f()) {
1336 assert(element is FunctionElement || element is VariableElement); 1342 assert(element is FunctionElement || element is VariableElement);
1337 return compiler.withCurrentElement(element, () { 1343 return compiler.withCurrentElement(element, () {
1338 // The [sourceElementStack] contains declaration elements. 1344 // The [sourceElementStack] contains declaration elements.
1339 sourceElementStack.add(element.declaration); 1345 sourceElementStack.add(element.declaration);
1340 var result = f(); 1346 var result = f();
1341 sourceElementStack.removeLast(); 1347 sourceElementStack.removeLast();
1342 return result; 1348 return result;
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 HInstruction typeInfo = buildLiteralList(rtiInputs); 3988 HInstruction typeInfo = buildLiteralList(rtiInputs);
3983 add(typeInfo); 3989 add(typeInfo);
3984 3990
3985 // Set the runtime type information on the object. 3991 // Set the runtime type information on the object.
3986 Element typeInfoSetterElement = backend.getSetRuntimeTypeInfo(); 3992 Element typeInfoSetterElement = backend.getSetRuntimeTypeInfo();
3987 pushInvokeStatic( 3993 pushInvokeStatic(
3988 null, 3994 null,
3989 typeInfoSetterElement, 3995 typeInfoSetterElement,
3990 <HInstruction>[newObject, typeInfo], 3996 <HInstruction>[newObject, typeInfo],
3991 backend.dynamicType); 3997 backend.dynamicType);
3998
3999 // The new object will now be referenced through the
4000 // `setRuntimeTypeInfo` call. We therefore set the type of that
4001 // instruction to be of the object's type.
4002 assert(stack.last is HInvokeStatic || stack.last == newObject);
3992 stack.last.instructionType = newObject.instructionType; 4003 stack.last.instructionType = newObject.instructionType;
3993 return pop(); 4004 return pop();
3994 } 4005 }
3995 4006
3996 handleNewSend(NewExpression node) { 4007 handleNewSend(NewExpression node) {
3997 Send send = node.send; 4008 Send send = node.send;
3998 bool isFixedList = false; 4009 bool isFixedList = false;
3999 bool isFixedListConstructorCall = 4010 bool isFixedListConstructorCall =
4000 Elements.isFixedListConstructorCall(elements[send], send, compiler); 4011 Elements.isFixedListConstructorCall(elements[send], send, compiler);
4001 bool isGrowableListConstructorCall = 4012 bool isGrowableListConstructorCall =
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
4857 } else { 4868 } else {
4858 visit(node.expression); 4869 visit(node.expression);
4859 value = pop(); 4870 value = pop();
4860 value = potentiallyCheckType(value, returnType); 4871 value = potentiallyCheckType(value, returnType);
4861 } 4872 }
4862 4873
4863 handleInTryStatement(); 4874 handleInTryStatement();
4864 emitReturn(value, node); 4875 emitReturn(value, node);
4865 } 4876 }
4866 4877
4867 void emitReturn(HInstruction value, Node node);
4868
4869 visitThrow(Throw node) { 4878 visitThrow(Throw node) {
4870 visitThrowExpression(node.expression); 4879 visitThrowExpression(node.expression);
4871 if (isReachable) { 4880 if (isReachable) {
4872 handleInTryStatement(); 4881 handleInTryStatement();
4873 push(new HThrowExpression(pop())); 4882 push(new HThrowExpression(pop()));
4874 isReachable = false; 4883 isReachable = false;
4875 } 4884 }
4876 } 4885 }
4877 4886
4878 visitTypeAnnotation(TypeAnnotation node) { 4887 visitTypeAnnotation(TypeAnnotation node) {
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
6382 DartType unaliased = type.unalias(builder.compiler); 6391 DartType unaliased = type.unalias(builder.compiler);
6383 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6392 if (unaliased is TypedefType) throw 'unable to unalias $type';
6384 unaliased.accept(this, builder); 6393 unaliased.accept(this, builder);
6385 } 6394 }
6386 6395
6387 void visitDynamicType(DynamicType type, SsaFromAstMixin builder) { 6396 void visitDynamicType(DynamicType type, SsaFromAstMixin builder) {
6388 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); 6397 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType');
6389 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6398 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6390 } 6399 }
6391 } 6400 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/from_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698