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

Unified Diff: sdk/lib/_internal/js_runtime/lib/js_helper.dart

Issue 1266903004: dart2js: Default values for static functions are now inside closures. (in the startup emitter). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/js_helper.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index f522a7703d916b017dedb9394b759673a92b219c..fd53e61d99b7ad7c47fd318e0d17b1e6c233ea5e 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -1256,14 +1256,16 @@ class Primitives {
return functionNoSuchMethod(function, arguments, namedArguments);
}
- var defaultValues = JS('var', r'#[#]', function,
+ var defaultValuesClosure = JS('var', r'#[#]', function,
JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY));
- if (JS('bool', 'typeof # == "function"', defaultValues)) {
- // Anonymous closures return a function that returns the default values
- // instead of providing the default values directly.
- defaultValues = JS('', '#()', defaultValues);
- }
- bool acceptsOptionalArguments = defaultValues != null;
+
+ bool acceptsOptionalArguments = defaultValuesClosure != null;
+
+ // Default values are stored inside a JavaScript closure to avoid
+ // accessing them too early.
+ var defaultValues = acceptsOptionalArguments
+ ? JS('', '#()', defaultValuesClosure)
+ : null;
var interceptor = getInterceptor(function);
var jsFunction = JS('', '#[#]', interceptor,
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698