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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/lib/interceptors.dart ('k') | tests/corelib/list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 1108f0f78ee2e506a1539adc5b801b0ebdb55f5d..3d55e7d8f5f63d26b865ebe444542bb278017a8c 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -2126,42 +2126,25 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
String builtinJsName(HInvokeInterceptor interceptor) {
+ // Don't count the target method or the receiver in the arity.
+ int arity = interceptor.inputs.length - 2;
HInstruction receiver = interceptor.inputs[1];
bool getter = interceptor.getter;
SourceString name = interceptor.name;
- if (receiver.isIndexablePrimitive()) {
- if (interceptor.isLengthGetter()) {
- return 'length';
- } else if (!getter
- && name == const SourceString('indexOf')
- && interceptor.inputs.length == 3) {
- // If there are three inputs, the start index is not given,
- // and we share the same default value with the native
- // implementation.
- return 'indexOf';
- } else if (!getter
- && name == const SourceString('lastIndexOf')
- && interceptor.inputs.length == 3) {
- // If there are three inputs, the start index is not given,
- // and we share the same default value with the native
- // implementation.
- return 'lastIndexOf';
- }
- }
-
- if (receiver.isExtendableArray() && !getter) {
- if (name == const SourceString('add')) {
+ if (interceptor.isLengthGetterOnStringOrArray()) {
+ return 'length';
+ } else if (receiver.isExtendableArray() && !getter) {
+ if (name == const SourceString('add') && arity == 1) {
return 'push';
}
- if (name == const SourceString('removeLast')) {
+ if (name == const SourceString('removeLast') && arity == 0) {
return 'pop';
}
- }
-
- if (receiver.isString() && !getter) {
- if (name == const SourceString('concat')
- && interceptor.inputs[2].isString()) {
+ } else if (receiver.isString() && !getter) {
+ if (name == const SourceString('concat') &&
+ arity == 1 &&
+ interceptor.inputs[2].isString()) {
return '+';
}
}
« 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