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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2691753002: Add deferred loading to Kernel. (Closed)
Patch Set: . Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 LocalFunctionElement element = astAdapter.getElement(target); 586 LocalFunctionElement element = astAdapter.getElement(target);
587 ClosureClassMap classMap = compiler.closureToClassMapper 587 ClosureClassMap classMap = compiler.closureToClassMapper
588 .getClosureToClassMapping(element.resolvedAst); 588 .getClosureToClassMapping(element.resolvedAst);
589 return classMap.callElement; 589 return classMap.callElement;
590 } 590 }
591 Element element = astAdapter.getElement(target); 591 Element element = astAdapter.getElement(target);
592 return element; 592 return element;
593 } 593 }
594 594
595 @override 595 @override
596 void visitCheckLibraryIsLoaded(ir.CheckLibraryIsLoaded checkLoad) {
597 HInstruction prefixConstant = graph.addConstantString(
598 new DartString.literal(checkLoad.import.name), closedWorld);
599 // TODO(efortuna): Optimization opportunity! Make this constant file name
600 // some sort of global constant (or a constant in the check loaded function)
601 // to look up rather than always passing in. Also note that the URI passed
602 // here is longer that in the original one, which called
603 // compiler.deferredLoadTask.getImportDeferName and then also needed the
604 // previsit function to hold the prefix element.
sra1 2017/02/14 03:14:06 How are we going to fix this (getting the shorter
Emily Fortuna 2017/02/14 20:56:28 This is what I was talking about last week. We can
sra1 2017/02/14 21:55:27 I'm concerned that two builds will generate differ
Emily Fortuna 2017/02/15 01:02:31 Fixed it properly.
605 HInstruction uriConstant = graph.addConstantString(
606 new DartString.literal(checkLoad.import.importedLibrary.importUri),
607 closedWorld);
608 _pushStaticInvocation(astAdapter.checkDeferredIsLoaded,
609 [prefixConstant, uriConstant], astAdapter.checkDeferredIsLoadedType);
610 }
611
612 @override
613 void visitLoadLibrary(ir.LoadLibrary loadLibrary) {
614 // TODO(efortuna): Source information!
615 push(new HInvokeStatic(
616 backend.helpers.loadLibraryWrapper,
617 [
618 graph.addConstantString(
619 new DartString.literal(loadLibrary.import.name), closedWorld)
620 ],
621 commonMasks.nonNullType,
622 targetCanThrow: false));
623 }
624
625 @override
596 void visitBlock(ir.Block block) { 626 void visitBlock(ir.Block block) {
597 assert(!isAborted()); 627 assert(!isAborted());
598 for (ir.Statement statement in block.statements) { 628 for (ir.Statement statement in block.statements) {
599 statement.accept(this); 629 statement.accept(this);
600 if (!isReachable) { 630 if (!isReachable) {
601 // The block has been aborted by a return or a throw. 631 // The block has been aborted by a return or a throw.
602 if (stack.isNotEmpty) { 632 if (stack.isNotEmpty) {
603 compiler.reporter.internalError( 633 compiler.reporter.internalError(
604 NO_LOCATION_SPANNABLE, 'Non-empty instruction stack.'); 634 NO_LOCATION_SPANNABLE, 'Non-empty instruction stack.');
605 } 635 }
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 } 1853 }
1824 1854
1825 @override 1855 @override
1826 void visitStaticGet(ir.StaticGet staticGet) { 1856 void visitStaticGet(ir.StaticGet staticGet) {
1827 ir.Member staticTarget = staticGet.target; 1857 ir.Member staticTarget = staticGet.target;
1828 if (staticTarget is ir.Procedure && 1858 if (staticTarget is ir.Procedure &&
1829 staticTarget.kind == ir.ProcedureKind.Getter) { 1859 staticTarget.kind == ir.ProcedureKind.Getter) {
1830 // Invoke the getter 1860 // Invoke the getter
1831 _pushStaticInvocation(staticTarget, const <HInstruction>[], 1861 _pushStaticInvocation(staticTarget, const <HInstruction>[],
1832 astAdapter.returnTypeOf(staticTarget)); 1862 astAdapter.returnTypeOf(staticTarget));
1833 } else if (staticTarget is ir.Field && staticTarget.isConst) { 1863 } else if (staticTarget is ir.Field &&
1834 assert(staticTarget.initializer != null); 1864 (staticTarget.isConst ||
1865 staticTarget.isFinal && !_isLazyStatic(staticTarget))) {
1835 stack.add(graph.addConstant( 1866 stack.add(graph.addConstant(
1836 astAdapter.getConstantFor(staticTarget.initializer), closedWorld)); 1867 astAdapter.getConstantFor(staticTarget.initializer), closedWorld));
1837 } else { 1868 } else {
1838 if (_isLazyStatic(staticTarget)) { 1869 if (_isLazyStatic(staticTarget)) {
1839 push(new HLazyStatic(astAdapter.getField(staticTarget), 1870 push(new HLazyStatic(astAdapter.getField(staticTarget),
1840 astAdapter.inferredTypeOf(staticTarget))); 1871 astAdapter.inferredTypeOf(staticTarget)));
1841 } else { 1872 } else {
1842 push(new HStatic(astAdapter.getMember(staticTarget), 1873 push(new HStatic(astAdapter.getMember(staticTarget),
1843 astAdapter.inferredTypeOf(staticTarget))); 1874 astAdapter.inferredTypeOf(staticTarget)));
1844 } 1875 }
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 enterBlock.setBlockFlow( 3258 enterBlock.setBlockFlow(
3228 new HTryBlockInformation( 3259 new HTryBlockInformation(
3229 kernelBuilder.wrapStatementGraph(bodyGraph), 3260 kernelBuilder.wrapStatementGraph(bodyGraph),
3230 exception, 3261 exception,
3231 kernelBuilder.wrapStatementGraph(catchGraph), 3262 kernelBuilder.wrapStatementGraph(catchGraph),
3232 kernelBuilder.wrapStatementGraph(finallyGraph)), 3263 kernelBuilder.wrapStatementGraph(finallyGraph)),
3233 exitBlock); 3264 exitBlock);
3234 kernelBuilder.inTryStatement = previouslyInTryStatement; 3265 kernelBuilder.inTryStatement = previouslyInTryStatement;
3235 } 3266 }
3236 } 3267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698