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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder.dart

Issue 1071133002: dart2js: create a 'types' table for each deferred unit. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library dart2js.js_emitter.program_builder; 5 library dart2js.js_emitter.program_builder;
6 6
7 import 'js_emitter.dart' show computeMixinClass; 7 import 'js_emitter.dart' show computeMixinClass;
8 import 'model.dart'; 8 import 'model.dart';
9 9
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 // this information anyway as they cannot be torn off or 540 // this information anyway as they cannot be torn off or
541 // reflected. 541 // reflected.
542 var body = element; 542 var body = element;
543 memberType = body.constructor.type; 543 memberType = body.constructor.type;
544 } else { 544 } else {
545 memberType = element.type; 545 memberType = element.type;
546 } 546 }
547 547
548 js.Expression functionType; 548 js.Expression functionType;
549 if (canTearOff || canBeReflected) { 549 if (canTearOff || canBeReflected) {
550 functionType = _generateFunctionType(memberType); 550 OutputUnit outputUnit =
551 _compiler.deferredLoadTask.outputUnitForElement(element);
552 functionType = _generateFunctionType(memberType, outputUnit);
551 } 553 }
552 554
553 int requiredParameterCount; 555 int requiredParameterCount;
554 var /* List | Map */ optionalParameterDefaultValues; 556 var /* List | Map */ optionalParameterDefaultValues;
555 if (canBeApplied || canBeReflected) { 557 if (canBeApplied || canBeReflected) {
556 FunctionSignature signature = element.functionSignature; 558 FunctionSignature signature = element.functionSignature;
557 requiredParameterCount = signature.requiredParameterCount; 559 requiredParameterCount = signature.requiredParameterCount;
558 optionalParameterDefaultValues = 560 optionalParameterDefaultValues =
559 _computeParameterDefaultValues(signature); 561 _computeParameterDefaultValues(signature);
560 } 562 }
561 563
562 return new InstanceMethod(element, name, code, 564 return new InstanceMethod(element, name, code,
563 _generateParameterStubs(element, canTearOff), callName, 565 _generateParameterStubs(element, canTearOff), callName,
564 needsTearOff: canTearOff, tearOffName: tearOffName, 566 needsTearOff: canTearOff, tearOffName: tearOffName,
565 isClosure: isClosure, aliasName: aliasName, 567 isClosure: isClosure, aliasName: aliasName,
566 canBeApplied: canBeApplied, canBeReflected: canBeReflected, 568 canBeApplied: canBeApplied, canBeReflected: canBeReflected,
567 requiredParameterCount: requiredParameterCount, 569 requiredParameterCount: requiredParameterCount,
568 optionalParameterDefaultValues: optionalParameterDefaultValues, 570 optionalParameterDefaultValues: optionalParameterDefaultValues,
569 functionType: functionType); 571 functionType: functionType);
570 } 572 }
571 573
572 js.Expression _generateFunctionType(DartType type) { 574 js.Expression _generateFunctionType(DartType type, OutputUnit outputUnit) {
573 if (type.containsTypeVariables) { 575 if (type.containsTypeVariables) {
574 js.Expression thisAccess = js.js(r'this.$receiver'); 576 js.Expression thisAccess = js.js(r'this.$receiver');
575 return backend.rti.getSignatureEncoding(type, thisAccess); 577 return backend.rti.getSignatureEncoding(type, thisAccess);
576 } else { 578 } else {
577 return js.number(backend.emitter.metadataCollector.reifyType(type)); 579 return js.number(backend.emitter.metadataCollector.
580 reifyTypeForOutputUnit(type, outputUnit));
578 } 581 }
579 } 582 }
580 583
581 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element, 584 List<ParameterStubMethod> _generateParameterStubs(FunctionElement element,
582 bool canTearOff) { 585 bool canTearOff) {
583 586
584 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[]; 587 if (!_methodNeedsStubs(element)) return const <ParameterStubMethod>[];
585 588
586 ParameterStubGenerator generator = 589 ParameterStubGenerator generator =
587 new ParameterStubGenerator(_compiler, namer, backend); 590 new ParameterStubGenerator(_compiler, namer, backend);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 714
712 String callName = null; 715 String callName = null;
713 if (needsTearOff) { 716 if (needsTearOff) {
714 Selector callSelector = 717 Selector callSelector =
715 new Selector.fromElement(element).toCallSelector(); 718 new Selector.fromElement(element).toCallSelector();
716 callName = namer.invocationName(callSelector); 719 callName = namer.invocationName(callSelector);
717 } 720 }
718 js.Expression functionType; 721 js.Expression functionType;
719 DartType type = element.type; 722 DartType type = element.type;
720 if (needsTearOff || canBeReflected) { 723 if (needsTearOff || canBeReflected) {
721 functionType = _generateFunctionType(type); 724 OutputUnit outputUnit =
725 _compiler.deferredLoadTask.outputUnitForElement(element);
726 functionType = _generateFunctionType(type, outputUnit);
722 } 727 }
723 728
724 int requiredParameterCount; 729 int requiredParameterCount;
725 var /* List | Map */ optionalParameterDefaultValues; 730 var /* List | Map */ optionalParameterDefaultValues;
726 if (canBeApplied || canBeReflected) { 731 if (canBeApplied || canBeReflected) {
727 FunctionSignature signature = element.functionSignature; 732 FunctionSignature signature = element.functionSignature;
728 requiredParameterCount = signature.requiredParameterCount; 733 requiredParameterCount = signature.requiredParameterCount;
729 optionalParameterDefaultValues = 734 optionalParameterDefaultValues =
730 _computeParameterDefaultValues(signature); 735 _computeParameterDefaultValues(signature);
731 } 736 }
(...skipping 22 matching lines...) Expand all
754 _registry.registerConstant(outputUnit, constantValue); 759 _registry.registerConstant(outputUnit, constantValue);
755 assert(!_constants.containsKey(constantValue)); 760 assert(!_constants.containsKey(constantValue));
756 String name = namer.constantName(constantValue); 761 String name = namer.constantName(constantValue);
757 String constantObject = namer.globalObjectForConstant(constantValue); 762 String constantObject = namer.globalObjectForConstant(constantValue);
758 Holder holder = _registry.registerHolder(constantObject); 763 Holder holder = _registry.registerHolder(constantObject);
759 Constant constant = new Constant(name, holder, constantValue); 764 Constant constant = new Constant(name, holder, constantValue);
760 _constants[constantValue] = constant; 765 _constants[constantValue] = constant;
761 } 766 }
762 } 767 }
763 } 768 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698