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

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

Issue 201613006: Introduces the new syntax for deferred loading (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 */ 2919 */
2920 void generateInstanceGetterWithCompiledReceiver(ast.Send send, 2920 void generateInstanceGetterWithCompiledReceiver(ast.Send send,
2921 Selector selector, 2921 Selector selector,
2922 HInstruction receiver) { 2922 HInstruction receiver) {
2923 assert(Elements.isInstanceSend(send, elements)); 2923 assert(Elements.isInstanceSend(send, elements));
2924 assert(selector.isGetter()); 2924 assert(selector.isGetter());
2925 pushInvokeDynamic(send, selector, [receiver]); 2925 pushInvokeDynamic(send, selector, [receiver]);
2926 } 2926 }
2927 2927
2928 void generateGetter(ast.Send send, Element element) { 2928 void generateGetter(ast.Send send, Element element) {
2929 if (Elements.isStaticOrTopLevelField(element)) { 2929 if (element != null && element.isForeign(compiler)) {
2930 visitForeignGetter(send);
2931 } else if (Elements.isStaticOrTopLevelField(element)) {
2930 Constant value; 2932 Constant value;
2931 if (element.isField() && !element.isAssignable()) { 2933 if (element.isField() && !element.isAssignable()) {
2932 // A static final or const. Get its constant value and inline it if 2934 // A static final or const. Get its constant value and inline it if
2933 // the value can be compiled eagerly. 2935 // the value can be compiled eagerly.
2934 value = compiler.constantHandler.getConstantForVariable(element); 2936 value = compiler.constantHandler.getConstantForVariable(element);
2935 } 2937 }
2936 if (value != null) { 2938 if (value != null) {
2937 HConstant instruction = graph.addConstant(value, compiler); 2939 HConstant instruction = graph.addConstant(value, compiler);
2938 stack.add(instruction); 2940 stack.add(instruction);
2939 // The inferrer may have found a better type than the constant 2941 // The inferrer may have found a better type than the constant
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 handleForeignJsGetName(node); 3568 handleForeignJsGetName(node);
3567 } else if (name == 'JS_EFFECT') { 3569 } else if (name == 'JS_EFFECT') {
3568 stack.add(graph.addConstantNull(compiler)); 3570 stack.add(graph.addConstantNull(compiler));
3569 } else if (name == 'JS_INTERCEPTOR_CONSTANT') { 3571 } else if (name == 'JS_INTERCEPTOR_CONSTANT') {
3570 handleJsInterceptorConstant(node); 3572 handleJsInterceptorConstant(node);
3571 } else { 3573 } else {
3572 throw "Unknown foreign: ${selector}"; 3574 throw "Unknown foreign: ${selector}";
3573 } 3575 }
3574 } 3576 }
3575 3577
3578 visitForeignGetter(ast.Send node) {
3579 Element element = elements[node];
3580 // Until now we only handle these as getters.
3581 invariant(node, element.isDeferredLoaderGetter());
3582 FunctionElement deferredLoader = element;
3583 Element loadFunction = compiler.loadLibraryFunction;
3584 PrefixElement prefixElement = deferredLoader.enclosingElement;
3585 String loadId = compiler.deferredLoadTask
3586 .importDeferName[prefixElement.deferredImport];
3587 var inputs = [graph.addConstantString(
3588 new ast.DartString.literal(loadId), compiler)];
3589 push(new HInvokeStatic(loadFunction, inputs, backend.nonNullType,
3590 targetCanThrow: false));
3591 }
3592
3576 generateSuperNoSuchMethodSend(ast.Send node, 3593 generateSuperNoSuchMethodSend(ast.Send node,
3577 Selector selector, 3594 Selector selector,
3578 List<HInstruction> arguments) { 3595 List<HInstruction> arguments) {
3579 String name = selector.name; 3596 String name = selector.name;
3580 3597
3581 ClassElement cls = currentNonClosureClass; 3598 ClassElement cls = currentNonClosureClass;
3582 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD); 3599 Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD);
3583 if (compiler.enabledInvokeOn 3600 if (compiler.enabledInvokeOn
3584 && element.enclosingElement.declaration != compiler.objectClass) { 3601 && element.enclosingElement.declaration != compiler.objectClass) {
3585 // Register the call as dynamic if [noSuchMethod] on the super 3602 // Register the call as dynamic if [noSuchMethod] on the super
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
4072 if (!compiler.enableUserAssertions) { 4089 if (!compiler.enableUserAssertions) {
4073 stack.add(graph.addConstantNull(compiler)); 4090 stack.add(graph.addConstantNull(compiler));
4074 return; 4091 return;
4075 } 4092 }
4076 visitStaticSend(node); 4093 visitStaticSend(node);
4077 } 4094 }
4078 4095
4079 visitStaticSend(ast.Send node) { 4096 visitStaticSend(ast.Send node) {
4080 Selector selector = elements.getSelector(node); 4097 Selector selector = elements.getSelector(node);
4081 Element element = elements[node]; 4098 Element element = elements[node];
4082 if (element.isForeign(compiler)) { 4099 if (element.isForeign(compiler) && element.isFunction()) {
4083 visitForeignSend(node); 4100 visitForeignSend(node);
4084 return; 4101 return;
4085 } 4102 }
4086 if (element.isErroneous()) { 4103 if (element.isErroneous()) {
4087 // An erroneous element indicates that the funciton could not be resolved 4104 // An erroneous element indicates that the funciton could not be resolved
4088 // (a warning has been issued). 4105 // (a warning has been issued).
4089 generateThrowNoSuchMethod(node, 4106 generateThrowNoSuchMethod(node,
4090 getTargetName(element), 4107 getTargetName(element),
4091 argumentNodes: node.arguments); 4108 argumentNodes: node.arguments);
4092 return; 4109 return;
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after
6116 DartType unaliased = type.unalias(builder.compiler); 6133 DartType unaliased = type.unalias(builder.compiler);
6117 if (unaliased is TypedefType) throw 'unable to unalias $type'; 6134 if (unaliased is TypedefType) throw 'unable to unalias $type';
6118 unaliased.accept(this, builder); 6135 unaliased.accept(this, builder);
6119 } 6136 }
6120 6137
6121 void visitDynamicType(DynamicType type, SsaBuilder builder) { 6138 void visitDynamicType(DynamicType type, SsaBuilder builder) {
6122 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType'); 6139 ClassElement cls = builder.compiler.findHelper('DynamicRuntimeType');
6123 builder.push(new HDynamicType(type, new TypeMask.exact(cls))); 6140 builder.push(new HDynamicType(type, new TypeMask.exact(cls)));
6124 } 6141 }
6125 } 6142 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698