Chromium Code Reviews| Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| index 92cae8e90fea146f7c6c6e5fe14bdc0d8e5873b9..0d0d854bf43e3224916a5b5c2e3065cab2e44969 100644 |
| --- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| +++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart |
| @@ -1146,20 +1146,47 @@ class Primitives { |
| static applyFunctionWithPositionalArguments(Function function, |
| List positionalArguments) { |
| - int argumentCount = 0; |
| List arguments; |
| if (positionalArguments != null) { |
| if (JS('bool', '# instanceof Array', positionalArguments)) { |
| - arguments = positionalArguments; |
| + arguments = JS('JSArray', '#', positionalArguments); |
| } else { |
| arguments = new List.from(positionalArguments); |
| } |
| - argumentCount = JS('int', '#.length', arguments); |
| } else { |
| arguments = []; |
| } |
| + if (arguments.length == 0) { |
| + String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX0); |
| + if (JS('bool', '!!#[#]', function, selectorName)) { |
| + return JS('', '#[#]()', function, selectorName); |
| + } |
| + } else if (arguments.length == 1) { |
| + String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX1); |
| + if (JS('bool', '!!#[#]', function, selectorName)) { |
| + return JS('', '#[#](#)', function, selectorName, arguments[0]); |
| + } |
| + } else if (arguments.length == 2) { |
| + String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX2); |
| + if (JS('bool', '!!#[#]', function, selectorName)) { |
| + return JS('', '#[#](#,#)', function, selectorName, |
| + arguments[0], arguments[1]); |
| + } |
| + } else if (arguments.length == 3) { |
| + String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX3); |
| + if (JS('bool', '!!#[#]', function, selectorName)) { |
| + return JS('', '#[#](#,#,#)', function, selectorName, |
| + arguments[0], arguments[1], arguments[2]); |
|
sra1
2015/03/25 03:16:29
I would not surprise me if the array bounds checks
floitsch
2015/03/25 22:58:30
I was sure I had tested it, but you are (unfortuna
|
| + } |
| + } |
| + return _genericApplyFunctionWithPositionalArguments(function, arguments); |
| + } |
| + |
| + static _genericApplyFunctionWithPositionalArguments(Function function, |
| + List arguments) { |
| + int argumentCount = arguments.length; |
| String selectorName = |
| '${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$$argumentCount'; |
| var jsFunction = JS('var', '#[#]', function, selectorName); |
| @@ -1168,13 +1195,13 @@ class Primitives { |
| jsFunction = JS('', '#["call*"]', interceptor); |
| if (jsFunction == null) { |
| - return functionNoSuchMethod(function, positionalArguments, null); |
| + return functionNoSuchMethod(function, arguments, null); |
| } |
| ReflectionInfo info = new ReflectionInfo(jsFunction); |
| int maxArgumentCount = info.requiredParameterCount + |
| info.optionalParameterCount; |
| if (info.areOptionalParametersNamed || maxArgumentCount < argumentCount) { |
| - return functionNoSuchMethod(function, positionalArguments, null); |
| + return functionNoSuchMethod(function, arguments, null); |
| } |
| arguments = new List.from(arguments); |
| for (int pos = argumentCount; pos < maxArgumentCount; pos++) { |