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

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

Issue 11365170: Start new design for interceptors and implement String.charCodeAt with it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 } 1513 }
1514 } 1514 }
1515 1515
1516 js.Call jsPropertyCall(js.Expression receiver, 1516 js.Call jsPropertyCall(js.Expression receiver,
1517 String fieldName, 1517 String fieldName,
1518 List<js.Expression> arguments) { 1518 List<js.Expression> arguments) {
1519 return new js.Call(new js.PropertyAccess.field(receiver, fieldName), 1519 return new js.Call(new js.PropertyAccess.field(receiver, fieldName),
1520 arguments); 1520 arguments);
1521 } 1521 }
1522 1522
1523 // TODO(ngeoffray): Once we remove the old interceptors, we can
ahe 2012/11/12 13:24:11 Perhaps elaborate on what the hack is.
ngeoffray 2012/11/13 11:45:16 Done.
1524 // start using HInvokeInterceptor to represent interceptor calls on
1525 // an Interceptor class.
1526 bool isInterceptorCall(HInvokeDynamicMethod node) {
1527 return node.inputs.length - 1 != node.selector.argumentCount;
1528 }
1529
1523 visitInvokeDynamicMethod(HInvokeDynamicMethod node) { 1530 visitInvokeDynamicMethod(HInvokeDynamicMethod node) {
1524 use(node.receiver); 1531 use(node.receiver);
1525 js.Expression object = pop(); 1532 js.Expression object = pop();
1526 SourceString name = node.selector.name; 1533 SourceString name = node.selector.name;
1527 String methodName; 1534 String methodName;
1528 List<js.Expression> arguments; 1535 List<js.Expression> arguments;
1529 Element target = node.element; 1536 Element target = node.element;
1530 1537
1531 // Avoid adding the generative constructor name to the list of 1538 // Avoid adding the generative constructor name to the list of
1532 // seen selectors. 1539 // seen selectors.
1533 if (target != null && target.isGenerativeConstructorBody()) { 1540 if (target != null && target.isGenerativeConstructorBody()) {
1534 methodName = name.slowToString(); 1541 methodName = name.slowToString();
1535 arguments = visitArguments(node.inputs); 1542 arguments = visitArguments(node.inputs);
1536 } else { 1543 } else {
1537 methodName = backend.namer.instanceMethodInvocationName( 1544 methodName = backend.namer.instanceMethodInvocationName(
1538 node.selector.library, name, node.selector); 1545 node.selector.library, name, node.selector);
1539 arguments = visitArguments(node.inputs); 1546 arguments = visitArguments(node.inputs);
1540 bool inLoop = node.block.enclosingLoopHeader != null; 1547 bool inLoop = node.block.enclosingLoopHeader != null;
1541 1548
1542 // Register this invocation to collect the types used at all call sites. 1549 // Register this invocation to collect the types used at all call sites.
1543 Selector selector = getOptimizedSelectorFor(node, node.selector); 1550 Selector selector = getOptimizedSelectorFor(node, node.selector);
1544 backend.registerDynamicInvocation(node, selector, types); 1551 // TODO(ngeoffray): Remove the following restriction. Because
1552 // the second input of this interceptor call is the actual
1553 // receiver (the first is the interceptor), the backend gets
1554 // confused. We should pass a list of types instead of a node to
1555 // [registerDynamicInvocation].
1556 if (!isInterceptorCall(node)) {
1557 backend.registerDynamicInvocation(node, selector, types);
1558 }
1545 1559
1546 // If we don't know what we're calling or if we are calling a getter, 1560 // If we don't know what we're calling or if we are calling a getter,
1547 // we need to register that fact that we may be calling a closure 1561 // we need to register that fact that we may be calling a closure
1548 // with the same arguments. 1562 // with the same arguments.
1549 if (target == null || target.isGetter()) { 1563 if (target == null || target.isGetter()) {
1550 // TODO(kasperl): If we have a typed selector for the call, we 1564 // TODO(kasperl): If we have a typed selector for the call, we
1551 // may know something about the types of closures that need 1565 // may know something about the types of closures that need
1552 // the specific closure call method. 1566 // the specific closure call method.
1553 Selector call = new Selector.callClosureFrom(selector); 1567 Selector call = new Selector.callClosureFrom(selector);
1554 world.registerDynamicInvocation(call.name, call); 1568 world.registerDynamicInvocation(call.name, call);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 HInstruction input = node.inputs[0]; 1973 HInstruction input = node.inputs[0];
1960 if (input.isConstantNull()) { 1974 if (input.isConstantNull()) {
1961 pushStatement(new js.Return(null), node); 1975 pushStatement(new js.Return(null), node);
1962 } else { 1976 } else {
1963 use(node.inputs[0]); 1977 use(node.inputs[0]);
1964 pushStatement(new js.Return(pop()), node); 1978 pushStatement(new js.Return(pop()), node);
1965 } 1979 }
1966 } 1980 }
1967 1981
1968 visitThis(HThis node) { 1982 visitThis(HThis node) {
1969 push(new js.This()); 1983 if (compiler.isForeignClass(work.element.getEnclosingClass())){
ahe 2012/11/12 13:24:11 How about "interceptor class" instead of "foreign
ngeoffray 2012/11/13 11:45:16 Done.
1984 push(new js.VariableUse(variableNames.getName(node)), node);
1985 } else {
1986 push(new js.This());
1987 }
1970 } 1988 }
1971 1989
1972 visitThrow(HThrow node) { 1990 visitThrow(HThrow node) {
1973 if (node.isRethrow) { 1991 if (node.isRethrow) {
1974 use(node.inputs[0]); 1992 use(node.inputs[0]);
1975 pushStatement(new js.Throw(pop()), node); 1993 pushStatement(new js.Throw(pop()), node);
1976 } else { 1994 } else {
1977 generateThrowWithHelper(r'$throw', node.inputs[0]); 1995 generateThrowWithHelper(r'$throw', node.inputs[0]);
1978 } 1996 }
1979 } 1997 }
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 if (leftType.canBeNull() && rightType.canBeNull()) { 3098 if (leftType.canBeNull() && rightType.canBeNull()) {
3081 if (left.isConstantNull() || right.isConstantNull() || 3099 if (left.isConstantNull() || right.isConstantNull() ||
3082 (leftType.isPrimitive() && leftType == rightType)) { 3100 (leftType.isPrimitive() && leftType == rightType)) {
3083 return '=='; 3101 return '==';
3084 } 3102 }
3085 return null; 3103 return null;
3086 } else { 3104 } else {
3087 return '==='; 3105 return '===';
3088 } 3106 }
3089 } 3107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698