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

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

Issue 102833009: Redo "Dummy receiver optimization" (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 class ConstantEmitter { 7 class ConstantEmitter {
8 ConstantReferenceEmitter _referenceEmitter; 8 ConstantReferenceEmitter _referenceEmitter;
9 ConstantInitializerEmitter _initializerEmitter; 9 ConstantInitializerEmitter _initializerEmitter;
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return emitCanonicalVersion(constant); 137 return emitCanonicalVersion(constant);
138 } 138 }
139 139
140 jsAst.Expression visitConstructed(ConstructedConstant constant) { 140 jsAst.Expression visitConstructed(ConstructedConstant constant) {
141 return emitCanonicalVersion(constant); 141 return emitCanonicalVersion(constant);
142 } 142 }
143 143
144 jsAst.Expression visitInterceptor(InterceptorConstant constant) { 144 jsAst.Expression visitInterceptor(InterceptorConstant constant) {
145 return emitCanonicalVersion(constant); 145 return emitCanonicalVersion(constant);
146 } 146 }
147
148 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) {
149 return new jsAst.LiteralNumber('0');
150 }
147 } 151 }
148 152
149 /** 153 /**
150 * Visitor for generating JavaScript expressions to initialize [Constant]s. 154 * Visitor for generating JavaScript expressions to initialize [Constant]s.
151 * Do not use directly; use methods from [ConstantEmitter]. 155 * Do not use directly; use methods from [ConstantEmitter].
152 */ 156 */
153 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> { 157 class ConstantInitializerEmitter implements ConstantVisitor<jsAst.Expression> {
154 final Compiler compiler; 158 final Compiler compiler;
155 final Namer namer; 159 final Namer namer;
156 final ConstantReferenceEmitter referenceEmitter; 160 final ConstantReferenceEmitter referenceEmitter;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 [typeName]); 310 [typeName]);
307 } 311 }
308 312
309 jsAst.Expression visitInterceptor(InterceptorConstant constant) { 313 jsAst.Expression visitInterceptor(InterceptorConstant constant) {
310 return new jsAst.PropertyAccess.field( 314 return new jsAst.PropertyAccess.field(
311 new jsAst.VariableUse( 315 new jsAst.VariableUse(
312 getJsConstructor(constant.dispatchedType.element)), 316 getJsConstructor(constant.dispatchedType.element)),
313 'prototype'); 317 'prototype');
314 } 318 }
315 319
320 jsAst.Expression visitDummyReceiver(DummyReceiverConstant constant) {
321 return _reference(constant);
322 }
323
316 jsAst.Expression visitConstructed(ConstructedConstant constant) { 324 jsAst.Expression visitConstructed(ConstructedConstant constant) {
317 Element element = constant.type.element; 325 Element element = constant.type.element;
318 if (element.isForeign(compiler) 326 if (element.isForeign(compiler)
319 && element.name == 'JS_CONST') { 327 && element.name == 'JS_CONST') {
320 StringConstant str = constant.fields[0]; 328 StringConstant str = constant.fields[0];
321 String value = str.value.slowToString(); 329 String value = str.value.slowToString();
322 return new jsAst.LiteralExpression(stripComments(value)); 330 return new jsAst.LiteralExpression(stripComments(value));
323 } 331 }
324 jsAst.New instantiation = new jsAst.New( 332 jsAst.New instantiation = new jsAst.New(
325 new jsAst.VariableUse(getJsConstructor(constant.type.element)), 333 new jsAst.VariableUse(getJsConstructor(constant.type.element)),
(...skipping 25 matching lines...) Expand all
351 .map((DartType type) => 359 .map((DartType type) =>
352 rti.getTypeRepresentationWithHashes(type, (_){})); 360 rti.getTypeRepresentationWithHashes(type, (_){}));
353 jsAst.Expression argumentList = 361 jsAst.Expression argumentList =
354 new jsAst.LiteralString('[${arguments.join(', ')}]'); 362 new jsAst.LiteralString('[${arguments.join(', ')}]');
355 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()), 363 return new jsAst.Call(getHelperProperty(backend.getSetRuntimeTypeInfo()),
356 [value, argumentList]); 364 [value, argumentList]);
357 } 365 }
358 return value; 366 return value;
359 } 367 }
360 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698