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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 15697004: Add a proper HInvokeConstructorBody instead of mis-using HInvokeDynamicMethod. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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) 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 ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 } 1480 }
1481 1481
1482 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { 1482 visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
1483 use(node.receiver); 1483 use(node.receiver);
1484 js.Expression object = pop(); 1484 js.Expression object = pop();
1485 SourceString name = node.selector.name; 1485 SourceString name = node.selector.name;
1486 String methodName; 1486 String methodName;
1487 List<js.Expression> arguments = visitArguments(node.inputs); 1487 List<js.Expression> arguments = visitArguments(node.inputs);
1488 Element target = node.element; 1488 Element target = node.element;
1489 1489
1490 if (target != null) { 1490 if (target != null && !node.isInterceptedCall) {
1491 // Avoid adding the generative constructor name to the list of 1491 if (target == backend.jsArrayAdd) {
1492 // seen selectors. 1492 methodName = 'push';
1493 if (target.isGenerativeConstructorBody()) { 1493 } else if (target == backend.jsArrayRemoveLast) {
1494 methodName = name.slowToString(); 1494 methodName = 'pop';
1495 } else if (!node.isInterceptedCall) { 1495 } else if (target == backend.jsStringSplit) {
1496 if (target == backend.jsArrayAdd) { 1496 methodName = 'split';
1497 methodName = 'push'; 1497 // Split returns a List, so we make sure the backend knows the
1498 } else if (target == backend.jsArrayRemoveLast) { 1498 // list class is instantiated.
1499 methodName = 'pop'; 1499 world.registerInstantiatedClass(
1500 } else if (target == backend.jsStringSplit) { 1500 compiler.listClass, work.resolutionTree);
1501 methodName = 'split'; 1501 } else if (target == backend.jsStringConcat) {
1502 // Split returns a List, so we make sure the backend knows the 1502 push(new js.Binary('+', object, arguments[0]), node);
1503 // list class is instantiated. 1503 return;
1504 world.registerInstantiatedClass( 1504 } else if (target.isNative() && target.isFunction()
1505 compiler.listClass, work.resolutionTree); 1505 && !node.isInterceptedCall) {
1506 } else if (target == backend.jsStringConcat) { 1506 // A direct (i.e. non-interceptor) native call is the result of
1507 push(new js.Binary('+', object, arguments[0]), node); 1507 // optimization. The optimization ensures any type checks or
1508 return; 1508 // conversions have been satisified.
1509 } else if (target.isNative() && target.isFunction() 1509 methodName = target.fixedBackendName();
1510 && !node.isInterceptedCall) {
1511 // A direct (i.e. non-interceptor) native call is the result of
1512 // optimization. The optimization ensures any type checks or
1513 // conversions have been satisified.
1514 methodName = target.fixedBackendName();
1515 }
1516 } 1510 }
1517 } 1511 }
1518 1512
1519 if (methodName == null) { 1513 if (methodName == null) {
1520 methodName = backend.namer.invocationName(node.selector); 1514 methodName = backend.namer.invocationName(node.selector);
1521 registerMethodInvoke(node); 1515 registerMethodInvoke(node);
1522 } 1516 }
1523 push(jsPropertyCall(object, methodName, arguments), node); 1517 push(jsPropertyCall(object, methodName, arguments), node);
1524 } 1518 }
1525 1519
1520 void visitInvokeConstructorBody(HInvokeConstructorBody node) {
1521 use(node.inputs[0]);
1522 js.Expression object = pop();
1523 String methodName = backend.namer.getName(node.element);
1524 List<js.Expression> arguments = visitArguments(node.inputs);
1525 push(jsPropertyCall(object, methodName, arguments), node);
1526 }
1527
1526 void visitOneShotInterceptor(HOneShotInterceptor node) { 1528 void visitOneShotInterceptor(HOneShotInterceptor node) {
1527 List<js.Expression> arguments = visitArguments(node.inputs); 1529 List<js.Expression> arguments = visitArguments(node.inputs);
1528 var isolate = new js.VariableUse(backend.namer.CURRENT_ISOLATE); 1530 var isolate = new js.VariableUse(backend.namer.CURRENT_ISOLATE);
1529 Selector selector = getOptimizedSelectorFor(node, node.selector); 1531 Selector selector = getOptimizedSelectorFor(node, node.selector);
1530 String methodName = backend.registerOneShotInterceptor(selector); 1532 String methodName = backend.registerOneShotInterceptor(selector);
1531 push(jsPropertyCall(isolate, methodName, arguments), node); 1533 push(jsPropertyCall(isolate, methodName, arguments), node);
1532 if (selector.isGetter()) { 1534 if (selector.isGetter()) {
1533 registerGetter(node); 1535 registerGetter(node);
1534 } else if (selector.isSetter()) { 1536 } else if (selector.isSetter()) {
1535 registerSetter(node); 1537 registerSetter(node);
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 if (leftType.canBeNull() && rightType.canBeNull()) { 2990 if (leftType.canBeNull() && rightType.canBeNull()) {
2989 if (left.isConstantNull() || right.isConstantNull() || 2991 if (left.isConstantNull() || right.isConstantNull() ||
2990 (leftType.isPrimitive() && leftType == rightType)) { 2992 (leftType.isPrimitive() && leftType == rightType)) {
2991 return '=='; 2993 return '==';
2992 } 2994 }
2993 return null; 2995 return null;
2994 } else { 2996 } else {
2995 return '==='; 2997 return '===';
2996 } 2998 }
2997 } 2999 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698