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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 228063002: Construct literal maps using factory constructor. (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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/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 js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Element jsArrayAdd; 95 Element jsArrayAdd;
96 Element jsStringSplit; 96 Element jsStringSplit;
97 Element jsStringToString; 97 Element jsStringToString;
98 Element jsStringOperatorAdd; 98 Element jsStringOperatorAdd;
99 Element objectEquals; 99 Element objectEquals;
100 100
101 ClassElement typeLiteralClass; 101 ClassElement typeLiteralClass;
102 ClassElement mapLiteralClass; 102 ClassElement mapLiteralClass;
103 ClassElement constMapLiteralClass; 103 ClassElement constMapLiteralClass;
104 ClassElement typeVariableClass; 104 ClassElement typeVariableClass;
105 Element mapLiteralConstructor;
106 Element mapLiteralConstructorEmpty;
105 107
106 ClassElement noSideEffectsClass; 108 ClassElement noSideEffectsClass;
107 ClassElement noThrowsClass; 109 ClassElement noThrowsClass;
108 ClassElement noInlineClass; 110 ClassElement noInlineClass;
109 ClassElement irRepresentationClass; 111 ClassElement irRepresentationClass;
110 112
111 Element getInterceptorMethod; 113 Element getInterceptorMethod;
112 Element interceptedNames; 114 Element interceptedNames;
113 115
114 /** 116 /**
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } else if (cls == compiler.functionClass) { 723 } else if (cls == compiler.functionClass) {
722 enqueueClass(enqueuer, compiler.closureClass, elements); 724 enqueueClass(enqueuer, compiler.closureClass, elements);
723 } else if (cls == compiler.mapClass) { 725 } else if (cls == compiler.mapClass) {
724 // The backend will use a literal list to initialize the entries 726 // The backend will use a literal list to initialize the entries
725 // of the map. 727 // of the map.
726 enqueueClass(enqueuer, compiler.listClass, elements); 728 enqueueClass(enqueuer, compiler.listClass, elements);
727 enqueueClass(enqueuer, mapLiteralClass, elements); 729 enqueueClass(enqueuer, mapLiteralClass, elements);
728 // For map literals, the dependency between the implementation class 730 // For map literals, the dependency between the implementation class
729 // and [Map] is not visible, so we have to add it manually. 731 // and [Map] is not visible, so we have to add it manually.
730 rti.registerRtiDependency(mapLiteralClass, cls); 732 rti.registerRtiDependency(mapLiteralClass, cls);
731 enqueueInResolution(getMapMaker(), elements);
732 } else if (cls == compiler.boundClosureClass) { 733 } else if (cls == compiler.boundClosureClass) {
733 // TODO(ngeoffray): Move the bound closure class in the 734 // TODO(ngeoffray): Move the bound closure class in the
734 // backend. 735 // backend.
735 enqueueClass(enqueuer, compiler.boundClosureClass, elements); 736 enqueueClass(enqueuer, compiler.boundClosureClass, elements);
736 } else if (Elements.isNativeOrExtendsNative(cls)) { 737 } else if (Elements.isNativeOrExtendsNative(cls)) {
737 enqueue(enqueuer, getNativeInterceptorMethod, elements); 738 enqueue(enqueuer, getNativeInterceptorMethod, elements);
738 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies); 739 enqueueClass(enqueuer, jsInterceptorClass, compiler.globalDependencies);
739 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, elements); 740 enqueueClass(enqueuer, jsPlainJavaScriptObjectClass, elements);
741 } else if (cls == mapLiteralClass) {
742 // For map literals, the dependency between the implementation class
743 // and [Map] is not visible, so we have to add it manually.
744 Element getFactory(String name, int arity) {
745 return mapLiteralClass.patch.lookupConstructor(
746 new Selector.callConstructor(
747 name, mapLiteralClass.getLibrary(), arity),
748 (element) {
749 compiler.internalError(mapLiteralClass,
750 "Map literal class $mapLiteralClass missing "
751 "'$name' constructor"
752 " ${mapLiteralClass.constructors}");
753 });
754 }
755 mapLiteralConstructor = getFactory('_literal', 1);
756 mapLiteralConstructorEmpty = getFactory('_empty', 0);
757 enqueueInResolution(mapLiteralConstructor, elements);
758 enqueueInResolution(mapLiteralConstructorEmpty, elements);
740 } 759 }
741 } 760 }
742 if (cls == compiler.closureClass) { 761 if (cls == compiler.closureClass) {
743 enqueue(enqueuer, 762 enqueue(enqueuer,
744 compiler.findHelper('closureFromTearOff'), 763 compiler.findHelper('closureFromTearOff'),
745 elements); 764 elements);
746 } 765 }
747 ClassElement result = null; 766 ClassElement result = null;
748 if (cls == compiler.stringClass || cls == jsStringClass) { 767 if (cls == compiler.stringClass || cls == jsStringClass) {
749 addInterceptors(jsStringClass, enqueuer, elements); 768 addInterceptors(jsStringClass, enqueuer, elements);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 } 1460 }
1442 1461
1443 Element getClosureConverter() { 1462 Element getClosureConverter() {
1444 return compiler.findHelper('convertDartClosureToJS'); 1463 return compiler.findHelper('convertDartClosureToJS');
1445 } 1464 }
1446 1465
1447 Element getTraceFromException() { 1466 Element getTraceFromException() {
1448 return compiler.findHelper('getTraceFromException'); 1467 return compiler.findHelper('getTraceFromException');
1449 } 1468 }
1450 1469
1451 Element getMapMaker() {
1452 return compiler.findHelper('makeLiteralMap');
1453 }
1454
1455 Element getSetRuntimeTypeInfo() { 1470 Element getSetRuntimeTypeInfo() {
1456 return compiler.findHelper('setRuntimeTypeInfo'); 1471 return compiler.findHelper('setRuntimeTypeInfo');
1457 } 1472 }
1458 1473
1459 Element getGetRuntimeTypeInfo() { 1474 Element getGetRuntimeTypeInfo() {
1460 return compiler.findHelper('getRuntimeTypeInfo'); 1475 return compiler.findHelper('getRuntimeTypeInfo');
1461 } 1476 }
1462 1477
1463 Element getGetTypeArgumentByIndex() { 1478 Element getGetTypeArgumentByIndex() {
1464 return compiler.findHelper('getTypeArgumentByIndex'); 1479 return compiler.findHelper('getTypeArgumentByIndex');
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 } 1894 }
1880 } 1895 }
1881 1896
1882 /// Records that [constant] is used by [user.element]. 1897 /// Records that [constant] is used by [user.element].
1883 class Dependency { 1898 class Dependency {
1884 final Constant constant; 1899 final Constant constant;
1885 final TreeElements user; 1900 final TreeElements user;
1886 1901
1887 const Dependency(this.constant, this.user); 1902 const Dependency(this.constant, this.user);
1888 } 1903 }
1889
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698