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

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

Issue 10553034: Stop mapping indexOf/lastIndexOf directly to the JavaScript native on indexable primitives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « lib/compiler/implementation/lib/interceptors.dart ('k') | tests/corelib/list_test.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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 final JavaScriptBackend backend; 6 final JavaScriptBackend backend;
7 SsaCodeGeneratorTask(JavaScriptBackend backend) 7 SsaCodeGeneratorTask(JavaScriptBackend backend)
8 : this.backend = backend, 8 : this.backend = backend,
9 super(backend.compiler); 9 super(backend.compiler);
10 String get name() => 'SSA code generator'; 10 String get name() => 'SSA code generator';
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 use(node.inputs[2], JSPrecedence.EXPRESSION_PRECEDENCE); 2119 use(node.inputs[2], JSPrecedence.EXPRESSION_PRECEDENCE);
2120 buffer.add('] = '); 2120 buffer.add('] = ');
2121 use(node.inputs[3], JSPrecedence.ASSIGNMENT_PRECEDENCE); 2121 use(node.inputs[3], JSPrecedence.ASSIGNMENT_PRECEDENCE);
2122 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); 2122 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE);
2123 } else { 2123 } else {
2124 visitInvokeStatic(node); 2124 visitInvokeStatic(node);
2125 } 2125 }
2126 } 2126 }
2127 2127
2128 String builtinJsName(HInvokeInterceptor interceptor) { 2128 String builtinJsName(HInvokeInterceptor interceptor) {
2129 // Don't count the target method or the receiver in the arity.
2130 int arity = interceptor.inputs.length - 2;
2129 HInstruction receiver = interceptor.inputs[1]; 2131 HInstruction receiver = interceptor.inputs[1];
2130 bool getter = interceptor.getter; 2132 bool getter = interceptor.getter;
2131 SourceString name = interceptor.name; 2133 SourceString name = interceptor.name;
2132 2134
2133 if (receiver.isIndexablePrimitive()) { 2135 if (interceptor.isLengthGetterOnStringOrArray()) {
2134 if (interceptor.isLengthGetter()) { 2136 return 'length';
2135 return 'length'; 2137 } else if (receiver.isExtendableArray() && !getter) {
2136 } else if (!getter 2138 if (name == const SourceString('add') && arity == 1) {
2137 && name == const SourceString('indexOf')
2138 && interceptor.inputs.length == 3) {
2139 // If there are three inputs, the start index is not given,
2140 // and we share the same default value with the native
2141 // implementation.
2142 return 'indexOf';
2143 } else if (!getter
2144 && name == const SourceString('lastIndexOf')
2145 && interceptor.inputs.length == 3) {
2146 // If there are three inputs, the start index is not given,
2147 // and we share the same default value with the native
2148 // implementation.
2149 return 'lastIndexOf';
2150 }
2151 }
2152
2153 if (receiver.isExtendableArray() && !getter) {
2154 if (name == const SourceString('add')) {
2155 return 'push'; 2139 return 'push';
2156 } 2140 }
2157 if (name == const SourceString('removeLast')) { 2141 if (name == const SourceString('removeLast') && arity == 0) {
2158 return 'pop'; 2142 return 'pop';
2159 } 2143 }
2160 } 2144 } else if (receiver.isString() && !getter) {
2161 2145 if (name == const SourceString('concat') &&
2162 if (receiver.isString() && !getter) { 2146 arity == 1 &&
2163 if (name == const SourceString('concat') 2147 interceptor.inputs[2].isString()) {
2164 && interceptor.inputs[2].isString()) {
2165 return '+'; 2148 return '+';
2166 } 2149 }
2167 } 2150 }
2168 2151
2169 return null; 2152 return null;
2170 } 2153 }
2171 2154
2172 void visitInvokeInterceptor(HInvokeInterceptor node) { 2155 void visitInvokeInterceptor(HInvokeInterceptor node) {
2173 String builtin = builtinJsName(node); 2156 String builtin = builtinJsName(node);
2174 if (builtin !== null) { 2157 if (builtin !== null) {
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 startBailoutSwitch(); 2895 startBailoutSwitch();
2913 } 2896 }
2914 } 2897 }
2915 2898
2916 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { 2899 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) {
2917 if (labeledBlockInfo.body.start.hasGuards()) { 2900 if (labeledBlockInfo.body.start.hasGuards()) {
2918 endBailoutSwitch(); 2901 endBailoutSwitch();
2919 } 2902 }
2920 } 2903 }
2921 } 2904 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/interceptors.dart ('k') | tests/corelib/list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698