Remove full emitter version of Function.apply
Change-Id: Ib6abb717c815ec97964943c992d9cfd0d4dceec9
Reviewed-on: https://dart-review.googlesource.com/c/88884
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index f180c6c..cbd4d59 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -398,7 +398,6 @@
new BackendUsageBuilderImpl(compiler.frontendStrategy);
_checkedModeHelpers = new CheckedModeHelpers();
emitter = new CodeEmitterTask(compiler, generateSourceMap);
-
noSuchMethodRegistry = new NoSuchMethodRegistryImpl(
commonElements, compiler.frontendStrategy.createNoSuchMethodResolver());
functionCompiler = new SsaFunctionCompiler(
diff --git a/pkg/compiler/lib/src/ssa/graph_builder.dart b/pkg/compiler/lib/src/ssa/graph_builder.dart
index e42df10..7b78b8c 100644
--- a/pkg/compiler/lib/src/ssa/graph_builder.dart
+++ b/pkg/compiler/lib/src/ssa/graph_builder.dart
@@ -281,8 +281,6 @@
/// concrete SSA builder reports an error.
bool getFlagValue(String flagName) {
switch (flagName) {
- case 'IS_FULL_EMITTER':
- return false;
case 'MINIFIED':
return options.enableMinification;
case 'MUST_RETAIN_METADATA':
diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
index a5438a4..2d0f531 100644
--- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart
@@ -80,14 +80,6 @@
@patch
static apply(Function function, List positionalArguments,
[Map<Symbol, dynamic> namedArguments]) {
- // The lazy and startup emitter use a different implementation. To keep the
- // method small and inlinable, just select the method.
- return JS_GET_FLAG("IS_FULL_EMITTER")
- ? _apply1(function, positionalArguments, namedArguments)
- : _apply2(function, positionalArguments, namedArguments);
- }
-
- static _apply1(function, positionalArguments, namedArguments) {
return Primitives.applyFunction(
function,
positionalArguments,
@@ -95,15 +87,6 @@
// tree-shake _symbolMapToStringMap.
namedArguments == null ? null : _symbolMapToStringMap(namedArguments));
}
-
- static _apply2(function, positionalArguments, namedArguments) {
- return Primitives.applyFunction2(
- function,
- positionalArguments,
- // Use this form so that if namedArguments is always null, we can
- // tree-shake _symbolMapToStringMap.
- namedArguments == null ? null : _symbolMapToStringMap(namedArguments));
- }
}
// Patch for Expando implementation.
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 3338e9d..61e7182 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -1132,7 +1132,7 @@
* "call$4", then the object's "call$4" property should be used as if it was
* the value of the catch-all property.
*/
- static applyFunction2(Function function, List positionalArguments,
+ static applyFunction(Function function, List positionalArguments,
Map<String, dynamic> namedArguments) {
// Fast shortcut for the common case.
if (JS('bool', '# instanceof Array', positionalArguments) &&
@@ -1300,162 +1300,6 @@
}
}
- static applyFunction(Function function, List positionalArguments,
- Map<String, dynamic> namedArguments) {
- // Dispatch on presence of named arguments to improve tree-shaking.
- //
- // This dispatch is as simple as possible to help the compiler detect the
- // common case of `null` namedArguments, either via inlining or
- // specialization.
- return namedArguments == null
- ? applyFunctionWithPositionalArguments(function, positionalArguments)
- : applyFunctionWithNamedArguments(
- function, positionalArguments, namedArguments);
- }
-
- static applyFunctionWithPositionalArguments(
- Function function, List positionalArguments) {
- List arguments;
-
- if (positionalArguments != null) {
- if (JS('bool', '# instanceof Array', positionalArguments)) {
- arguments = JS('JSArray', '#', positionalArguments);
- } else {
- arguments = new List.from(positionalArguments);
- }
- } 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('', '#[#](#[0])', function, selectorName, arguments);
- }
- } else if (arguments.length == 2) {
- String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX2);
- if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1])', function, selectorName, arguments,
- arguments);
- }
- } else if (arguments.length == 3) {
- String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX3);
- if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1],#[2])', function, selectorName, arguments,
- arguments, arguments);
- }
- } else if (arguments.length == 4) {
- String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX4);
- if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1],#[2],#[3])', function, selectorName,
- arguments, arguments, arguments, arguments);
- }
- } else if (arguments.length == 5) {
- String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX5);
- if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1],#[2],#[3],#[4])', function, selectorName,
- arguments, arguments, arguments, arguments, arguments);
- }
- }
- 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);
- if (jsFunction == null) {
- var interceptor = getInterceptor(function);
- jsFunction =
- JS('', '#[#]', interceptor, JS_GET_NAME(JsGetName.CALL_CATCH_ALL));
-
- if (jsFunction == null) {
- return functionNoSuchMethod(function, arguments, null);
- }
- ReflectionInfo info = new ReflectionInfo(jsFunction);
- int requiredArgumentCount = info.requiredParameterCount;
- int maxArgumentCount =
- requiredArgumentCount + info.optionalParameterCount;
- if (info.areOptionalParametersNamed ||
- requiredArgumentCount > argumentCount ||
- maxArgumentCount < argumentCount) {
- return functionNoSuchMethod(function, arguments, null);
- }
- arguments = new List.from(arguments);
- for (int pos = argumentCount; pos < maxArgumentCount; pos++) {
- arguments.add(getMetadata(info.defaultValue(pos)));
- }
- }
- // We bound 'this' to [function] because of how we compile
- // closures: escaped local variables are stored and accessed through
- // [function].
- return JS('var', '#.apply(#, #)', jsFunction, function, arguments);
- }
-
- static applyFunctionWithNamedArguments(Function function,
- List positionalArguments, Map<String, dynamic> namedArguments) {
- if (namedArguments.isEmpty) {
- return applyFunctionWithPositionalArguments(
- function, positionalArguments);
- }
- // TODO(ahe): The following code can be shared with
- // JsInstanceMirror.invoke.
- var interceptor = getInterceptor(function);
- var jsFunction =
- JS('', '#[#]', interceptor, JS_GET_NAME(JsGetName.CALL_CATCH_ALL));
-
- if (jsFunction == null) {
- return functionNoSuchMethod(
- function, positionalArguments, namedArguments);
- }
- ReflectionInfo info = new ReflectionInfo(jsFunction);
- if (info == null || !info.areOptionalParametersNamed) {
- return functionNoSuchMethod(
- function, positionalArguments, namedArguments);
- }
-
- if (positionalArguments != null) {
- positionalArguments = new List.from(positionalArguments);
- } else {
- positionalArguments = [];
- }
- // Check the number of positional arguments is valid.
- if (info.requiredParameterCount != positionalArguments.length) {
- return functionNoSuchMethod(
- function, positionalArguments, namedArguments);
- }
- var defaultArguments = new Map();
- for (int i = 0; i < info.optionalParameterCount; i++) {
- int index = i + info.requiredParameterCount;
- var parameterName = info.parameterNameInOrder(index);
- var value = info.defaultValueInOrder(index);
- var defaultValue = getMetadata(value);
- defaultArguments[parameterName] = defaultValue;
- }
- bool bad = false;
- namedArguments.forEach((String parameter, value) {
- if (defaultArguments.containsKey(parameter)) {
- defaultArguments[parameter] = value;
- } else {
- // Extraneous named argument.
- bad = true;
- }
- });
- if (bad) {
- return functionNoSuchMethod(
- function, positionalArguments, namedArguments);
- }
- positionalArguments.addAll(defaultArguments.values);
- return JS('', '#.apply(#, #)', jsFunction, function, positionalArguments);
- }
-
static StackTrace extractStackTrace(Error error) {
return getTraceFromException(JS('', r'#.$thrownJsError', error));
}