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

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

Issue 247863005: Revert "Insert checks before deferred calls and accesses." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months 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 implement [TypedElement.type] because our 9 * methods. We need to implement [TypedElement.type] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 1165
1166 // Bail out early if the inlining decision is in the cache and we can't 1166 // Bail out early if the inlining decision is in the cache and we can't
1167 // inline (no need to check the hard constraints). 1167 // inline (no need to check the hard constraints).
1168 bool cachedCanBeInlined = 1168 bool cachedCanBeInlined =
1169 backend.inlineCache.canInline(function, insideLoop: insideLoop); 1169 backend.inlineCache.canInline(function, insideLoop: insideLoop);
1170 if (cachedCanBeInlined == false) return false; 1170 if (cachedCanBeInlined == false) return false;
1171 1171
1172 bool meetsHardConstraints() { 1172 bool meetsHardConstraints() {
1173 // Don't inline from one output unit to another. If something is deferred 1173 // Don't inline from one output unit to another. If something is deferred
1174 // it is to save space in the loading code. 1174 // it is to save space in the loading code.
1175 if (!compiler.deferredLoadTask 1175 var getOutputUnit = compiler.deferredLoadTask.outputUnitForElement;
1176 .inSameOutputUnit(element,compiler.currentElement)) { 1176 if (getOutputUnit(element) !=
1177 getOutputUnit(compiler.currentElement)) {
1177 return false; 1178 return false;
1178 } 1179 }
1179 if (compiler.disableInlining) return false; 1180 if (compiler.disableInlining) return false;
1180 1181
1181 assert(selector != null 1182 assert(selector != null
1182 || Elements.isStaticOrTopLevel(element) 1183 || Elements.isStaticOrTopLevel(element)
1183 || element.isGenerativeConstructorBody()); 1184 || element.isGenerativeConstructorBody());
1184 if (selector != null && !selector.applies(function, compiler)) { 1185 if (selector != null && !selector.applies(function, compiler)) {
1185 return false; 1186 return false;
1186 } 1187 }
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2921 * [selector]. 2922 * [selector].
2922 */ 2923 */
2923 void generateInstanceGetterWithCompiledReceiver(ast.Send send, 2924 void generateInstanceGetterWithCompiledReceiver(ast.Send send,
2924 Selector selector, 2925 Selector selector,
2925 HInstruction receiver) { 2926 HInstruction receiver) {
2926 assert(Elements.isInstanceSend(send, elements)); 2927 assert(Elements.isInstanceSend(send, elements));
2927 assert(selector.isGetter()); 2928 assert(selector.isGetter());
2928 pushInvokeDynamic(send, selector, [receiver]); 2929 pushInvokeDynamic(send, selector, [receiver]);
2929 } 2930 }
2930 2931
2931 /// Inserts a call to checkDeferredIsLoaded if the send has a prefix that
2932 /// resolves to a deferred library.
2933 void generateIsDeferredLoadedCheckIfNeeded(ast.Send node) {
2934 DeferredLoadTask deferredTask = compiler.deferredLoadTask;
2935 PrefixElement prefixElement =
2936 deferredTask.deferredPrefixElement(node, elements);
2937 if (prefixElement != null) {
2938 String loadId =
2939 deferredTask.importDeferName[prefixElement.deferredImport];
2940 HInstruction loadIdConstant = addConstantString(loadId);
2941 String uri = prefixElement.deferredImport.uri.dartString.slowToString();
2942 HInstruction uriConstant = addConstantString(uri);
2943 Element helper = backend.getCheckDeferredIsLoaded();
2944 pushInvokeStatic(node, helper, [loadIdConstant, uriConstant]);
2945 pop();
2946 }
2947 }
2948
2949 void generateGetter(ast.Send send, Element element) { 2932 void generateGetter(ast.Send send, Element element) {
2950 if (element != null && element.isForeign(compiler)) { 2933 if (element != null && element.isForeign(compiler)) {
2951 visitForeignGetter(send); 2934 visitForeignGetter(send);
2952 } else if (Elements.isStaticOrTopLevelField(element)) { 2935 } else if (Elements.isStaticOrTopLevelField(element)) {
2953 Constant value; 2936 Constant value;
2954 if (element.isField() && !element.isAssignable()) { 2937 if (element.isField() && !element.isAssignable()) {
2955 // A static final or const. Get its constant value and inline it if 2938 // A static final or const. Get its constant value and inline it if
2956 // the value can be compiled eagerly. 2939 // the value can be compiled eagerly.
2957 value = backend.constants.getConstantForVariable(element); 2940 value = backend.constants.getConstantForVariable(element);
2958 } 2941 }
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
3931 // The new object will now be referenced through the 3914 // The new object will now be referenced through the
3932 // `setRuntimeTypeInfo` call. We therefore set the type of that 3915 // `setRuntimeTypeInfo` call. We therefore set the type of that
3933 // instruction to be of the object's type. 3916 // instruction to be of the object's type.
3934 assert(stack.last is HInvokeStatic || stack.last == newObject); 3917 assert(stack.last is HInvokeStatic || stack.last == newObject);
3935 stack.last.instructionType = newObject.instructionType; 3918 stack.last.instructionType = newObject.instructionType;
3936 return pop(); 3919 return pop();
3937 } 3920 }
3938 3921
3939 handleNewSend(ast.NewExpression node) { 3922 handleNewSend(ast.NewExpression node) {
3940 ast.Send send = node.send; 3923 ast.Send send = node.send;
3941 generateIsDeferredLoadedCheckIfNeeded(send);
3942
3943 bool isFixedList = false; 3924 bool isFixedList = false;
3944 bool isFixedListConstructorCall = 3925 bool isFixedListConstructorCall =
3945 Elements.isFixedListConstructorCall(elements[send], send, compiler); 3926 Elements.isFixedListConstructorCall(elements[send], send, compiler);
3946 bool isGrowableListConstructorCall = 3927 bool isGrowableListConstructorCall =
3947 Elements.isGrowableListConstructorCall(elements[send], send, compiler); 3928 Elements.isGrowableListConstructorCall(elements[send], send, compiler);
3948 3929
3949 TypeMask computeType(element) { 3930 TypeMask computeType(element) {
3950 Element originalElement = elements[send]; 3931 Element originalElement = elements[send];
3951 if (isFixedListConstructorCall 3932 if (isFixedListConstructorCall
3952 || Elements.isFilledListConstructorCall( 3933 || Elements.isFilledListConstructorCall(
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 } 4165 }
4185 if (element.isErroneous()) { 4166 if (element.isErroneous()) {
4186 // An erroneous element indicates that the funciton could not be resolved 4167 // An erroneous element indicates that the funciton could not be resolved
4187 // (a warning has been issued). 4168 // (a warning has been issued).
4188 generateThrowNoSuchMethod(node, 4169 generateThrowNoSuchMethod(node,
4189 getTargetName(element), 4170 getTargetName(element),
4190 argumentNodes: node.arguments); 4171 argumentNodes: node.arguments);
4191 return; 4172 return;
4192 } 4173 }
4193 invariant(element, !element.isGenerativeConstructor()); 4174 invariant(element, !element.isGenerativeConstructor());
4194 generateIsDeferredLoadedCheckIfNeeded(node);
4195 if (element.isFunction()) { 4175 if (element.isFunction()) {
4196 var inputs = <HInstruction>[]; 4176 var inputs = <HInstruction>[];
4197 // TODO(5347): Try to avoid the need for calling [implementation] before 4177 // TODO(5347): Try to avoid the need for calling [implementation] before
4198 // calling [addStaticSendArgumentsToList]. 4178 // calling [addStaticSendArgumentsToList].
4199 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments, 4179 bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
4200 element.implementation, 4180 element.implementation,
4201 inputs); 4181 inputs);
4202 if (!succeeded) { 4182 if (!succeeded) {
4203 generateWrongArgumentCountError(node, element, node.arguments); 4183 generateWrongArgumentCountError(node, element, node.arguments);
4204 return; 4184 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 HInstruction target = pop(); 4240 HInstruction target = pop();
4261 Selector selector = elements.getSelector(node); 4241 Selector selector = elements.getSelector(node);
4262 List<HInstruction> inputs = <HInstruction>[target]; 4242 List<HInstruction> inputs = <HInstruction>[target];
4263 addDynamicSendArgumentsToList(node, inputs); 4243 addDynamicSendArgumentsToList(node, inputs);
4264 Selector closureSelector = new Selector.callClosureFrom(selector); 4244 Selector closureSelector = new Selector.callClosureFrom(selector);
4265 push(new HInvokeClosure(closureSelector, inputs, backend.dynamicType)); 4245 push(new HInvokeClosure(closureSelector, inputs, backend.dynamicType));
4266 } 4246 }
4267 } 4247 }
4268 4248
4269 visitGetterSend(ast.Send node) { 4249 visitGetterSend(ast.Send node) {
4270 generateIsDeferredLoadedCheckIfNeeded(node);
4271 generateGetter(node, elements[node]); 4250 generateGetter(node, elements[node]);
4272 } 4251 }
4273 4252
4274 // TODO(antonm): migrate rest of SsaFromAstMixin to internalError. 4253 // TODO(antonm): migrate rest of SsaFromAstMixin to internalError.
4275 internalError(String reason, {ast.Node node}) { 4254 internalError(String reason, {ast.Node node}) {
4276 compiler.internalError(node, reason); 4255 compiler.internalError(node, reason);
4277 } 4256 }
4278 4257
4279 void generateError(ast.Node node, String message, Element helper) { 4258 void generateError(ast.Node node, String message, Element helper) {
4280 HInstruction errorMessage = addConstantString(message); 4259 HInstruction errorMessage = addConstantString(message);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 } else { 4508 } else {
4530 visit(arguments.head); 4509 visit(arguments.head);
4531 assert(arguments.tail.isEmpty); 4510 assert(arguments.tail.isEmpty);
4532 rhs = pop(); 4511 rhs = pop();
4533 } 4512 }
4534 visitBinary(receiver, node.assignmentOperator, rhs, 4513 visitBinary(receiver, node.assignmentOperator, rhs,
4535 elements.getOperatorSelectorInComplexSendSet(node), node); 4514 elements.getOperatorSelectorInComplexSendSet(node), node);
4536 } 4515 }
4537 4516
4538 visitSendSet(ast.SendSet node) { 4517 visitSendSet(ast.SendSet node) {
4539 generateIsDeferredLoadedCheckIfNeeded(node);
4540 Element element = elements[node]; 4518 Element element = elements[node];
4541 if (!Elements.isUnresolved(element) && element.impliesType()) { 4519 if (!Elements.isUnresolved(element) && element.impliesType()) {
4542 ast.Identifier selector = node.selector; 4520 ast.Identifier selector = node.selector;
4543 generateThrowNoSuchMethod(node, selector.source, 4521 generateThrowNoSuchMethod(node, selector.source,
4544 argumentNodes: node.arguments); 4522 argumentNodes: node.arguments);
4545 return; 4523 return;
4546 } 4524 }
4547 ast.Operator op = node.assignmentOperator; 4525 ast.Operator op = node.assignmentOperator;
4548 if (node.isSuperCall) { 4526 if (node.isSuperCall) {
4549 HInstruction result; 4527 HInstruction result;
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
6292 DartType unaliased = type.unalias(builder.compiler); 6270 DartType unaliased = type.unalias(builder.compiler);
6293 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6271 if (unaliased is TypedefType) throw 'unable to unalias $type';
6294 unaliased.accept(this, builder); 6272 unaliased.accept(this, builder);
6295 } 6273 }
6296 6274
6297 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6275 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6298 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); 6276 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType');
6299 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6277 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6300 } 6278 }
6301 } 6279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698