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

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

Issue 108333007: tests for inlining between IR and AST functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 Element objectEquals; 100 Element objectEquals;
101 101
102 ClassElement typeLiteralClass; 102 ClassElement typeLiteralClass;
103 ClassElement mapLiteralClass; 103 ClassElement mapLiteralClass;
104 ClassElement constMapLiteralClass; 104 ClassElement constMapLiteralClass;
105 ClassElement typeVariableClass; 105 ClassElement typeVariableClass;
106 106
107 ClassElement noSideEffectsClass; 107 ClassElement noSideEffectsClass;
108 ClassElement noThrowsClass; 108 ClassElement noThrowsClass;
109 ClassElement noInlineClass; 109 ClassElement noInlineClass;
110 ClassElement irRepresentationClass;
110 111
111 Element getInterceptorMethod; 112 Element getInterceptorMethod;
112 Element interceptedNames; 113 Element interceptedNames;
113 114
114 /** 115 /**
115 * This element is a top-level variable (in generated output) that the 116 * This element is a top-level variable (in generated output) that the
116 * compiler initializes to a datastructure used to map from a Type to the 117 * compiler initializes to a datastructure used to map from a Type to the
117 * interceptor. See declaration of `mapTypeToInterceptor` in 118 * interceptor. See declaration of `mapTypeToInterceptor` in
118 * `interceptors.dart`. 119 * `interceptors.dart`.
119 */ 120 */
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 * libraries. 152 * libraries.
152 */ 153 */
153 ClassElement jsIndexingBehaviorInterface; 154 ClassElement jsIndexingBehaviorInterface;
154 155
155 /** 156 /**
156 * A collection of selectors that must have a one shot interceptor 157 * A collection of selectors that must have a one shot interceptor
157 * generated. 158 * generated.
158 */ 159 */
159 final Map<String, Selector> oneShotInterceptors; 160 final Map<String, Selector> oneShotInterceptors;
160 161
162 final Map<Element, bool> _enforceIrElements = <Element, bool>{};
ngeoffray 2013/12/17 12:52:33 Because this is for testing: maybe do it lazily, i
163
164 bool enforceIrRepresentation(Element element) {
165 // Testing [:== true:]is required because the lookup might return [:null:].
166 return _enforceIrElements[element] == true;
167 }
168
169 bool enforceAstRepresentation(Element element) {
170 // Testing [:== false:]is required because the lookup might return [:null:].
171 return _enforceIrElements[element] == false;
172 }
173
161 /** 174 /**
162 * The members of instantiated interceptor classes: maps a member name to the 175 * The members of instantiated interceptor classes: maps a member name to the
163 * list of members that have that name. This map is used by the codegen to 176 * list of members that have that name. This map is used by the codegen to
164 * know whether a send must be intercepted or not. 177 * know whether a send must be intercepted or not.
165 */ 178 */
166 final Map<String, Set<Element>> interceptedElements; 179 final Map<String, Set<Element>> interceptedElements;
167 // TODO(sra): Not all methods in the Set always require an interceptor. A 180 // TODO(sra): Not all methods in the Set always require an interceptor. A
168 // method may be mixed into a true interceptor *and* a plain class. For the 181 // method may be mixed into a true interceptor *and* a plain class. For the
169 // method to work on the interceptor class it needs to use the explicit 182 // method to work on the interceptor class it needs to use the explicit
170 // receiver. This constrains the call on a known plain receiver to pass the 183 // receiver. This constrains the call on a known plain receiver to pass the
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 indexablePrimitiveType = new TypeMask.nonNullSubtype(jsIndexableClass); 527 indexablePrimitiveType = new TypeMask.nonNullSubtype(jsIndexableClass);
515 readableArrayType = new TypeMask.nonNullSubclass(jsArrayClass); 528 readableArrayType = new TypeMask.nonNullSubclass(jsArrayClass);
516 mutableArrayType = new TypeMask.nonNullSubclass(jsMutableArrayClass); 529 mutableArrayType = new TypeMask.nonNullSubclass(jsMutableArrayClass);
517 fixedArrayType = new TypeMask.nonNullExact(jsFixedArrayClass); 530 fixedArrayType = new TypeMask.nonNullExact(jsFixedArrayClass);
518 extendableArrayType = new TypeMask.nonNullExact(jsExtendableArrayClass); 531 extendableArrayType = new TypeMask.nonNullExact(jsExtendableArrayClass);
519 nonNullType = compiler.typesTask.dynamicType.nonNullable(); 532 nonNullType = compiler.typesTask.dynamicType.nonNullable();
520 533
521 noSideEffectsClass = compiler.findHelper('NoSideEffects'); 534 noSideEffectsClass = compiler.findHelper('NoSideEffects');
522 noThrowsClass = compiler.findHelper('NoThrows'); 535 noThrowsClass = compiler.findHelper('NoThrows');
523 noInlineClass = compiler.findHelper('NoInline'); 536 noInlineClass = compiler.findHelper('NoInline');
537 irRepresentationClass = compiler.findHelper('IrRepresentation');
524 } 538 }
525 539
526 void validateInterceptorImplementsAllObjectMethods( 540 void validateInterceptorImplementsAllObjectMethods(
527 ClassElement interceptorClass) { 541 ClassElement interceptorClass) {
528 if (interceptorClass == null) return; 542 if (interceptorClass == null) return;
529 interceptorClass.ensureResolved(compiler); 543 interceptorClass.ensureResolved(compiler);
530 compiler.objectClass.forEachMember((_, Element member) { 544 compiler.objectClass.forEachMember((_, Element member) {
531 if (member.isGenerativeConstructor()) return; 545 if (member.isGenerativeConstructor()) return;
532 Element interceptorMember = interceptorClass.lookupMember(member.name); 546 Element interceptorMember = interceptorClass.lookupMember(member.name);
533 // Interceptors must override all Object methods due to calling convention 547 // Interceptors must override all Object methods due to calling convention
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 if (VERBOSE_OPTIMIZER_HINTS) { 1801 if (VERBOSE_OPTIMIZER_HINTS) {
1788 compiler.reportHere(element, "Cannot throw"); 1802 compiler.reportHere(element, "Cannot throw");
1789 } 1803 }
1790 compiler.world.registerCannotThrow(element); 1804 compiler.world.registerCannotThrow(element);
1791 } else if (cls == noSideEffectsClass) { 1805 } else if (cls == noSideEffectsClass) {
1792 hasNoSideEffects = true; 1806 hasNoSideEffects = true;
1793 if (VERBOSE_OPTIMIZER_HINTS) { 1807 if (VERBOSE_OPTIMIZER_HINTS) {
1794 compiler.reportHere(element, "Has no side effects"); 1808 compiler.reportHere(element, "Has no side effects");
1795 } 1809 }
1796 compiler.world.registerSideEffectsFree(element); 1810 compiler.world.registerSideEffectsFree(element);
1811 } else if (cls == irRepresentationClass) {
ngeoffray 2013/12/17 12:52:33 Do it lazily?
lukas 2013/12/17 13:03:43 Which part exactly? Note that the code is guarded
1812 ConstructedConstant classConstant = value;
1813 BoolConstant constant = classConstant.fields[0];
1814 _enforceIrElements[element] = constant.value;
1797 } 1815 }
1798 } 1816 }
1799 if (hasNoThrows && !hasNoInline) { 1817 if (hasNoThrows && !hasNoInline) {
1800 compiler.internalErrorOnElement( 1818 compiler.internalErrorOnElement(
1801 element, "@NoThrows() should always be combined with @NoInline"); 1819 element, "@NoThrows() should always be combined with @NoInline");
1802 } 1820 }
1803 if (hasNoSideEffects && !hasNoInline) { 1821 if (hasNoSideEffects && !hasNoInline) {
1804 compiler.internalErrorOnElement( 1822 compiler.internalErrorOnElement(
1805 element, "@NoSideEffects() should always be combined with @NoInline"); 1823 element, "@NoSideEffects() should always be combined with @NoInline");
1806 } 1824 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 copy(constant.values); 1880 copy(constant.values);
1863 copy(constant.protoValue); 1881 copy(constant.protoValue);
1864 copy(constant); 1882 copy(constant);
1865 } 1883 }
1866 1884
1867 void visitConstructed(ConstructedConstant constant) { 1885 void visitConstructed(ConstructedConstant constant) {
1868 copy(constant.fields); 1886 copy(constant.fields);
1869 copy(constant); 1887 copy(constant);
1870 } 1888 }
1871 } 1889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698