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 6cfcda8d7cb9a8c1d3d255b436f073557cae38ee..1f7cc7bc27a63efb299d6494b7a639fed1f176e9 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart |
@@ -2456,7 +2456,7 @@ abstract class Closure implements Function { |
* |
* V8 will share the underlying function code objects when the same string is |
* passed to "new Function". Shared function code objects can lead to |
- * sub-optimal performance due to polymorhism, and can be prevented by |
+ * sub-optimal performance due to polymorphism, and can be prevented by |
* ensuring the strings are different. |
*/ |
static int functionCounter = 0; |
@@ -2559,8 +2559,9 @@ abstract class Closure implements Function { |
: isCsp |
? JS('', 'function(a,b,c,d) {this.\$initialize(a,b,c,d)}') |
: JS('', |
- 'new Function("a,b,c,d", "this.\$initialize(a,b,c,d);" + #)', |
- functionCounter++); |
+ 'new Function("a,b,c,d" + #,' |
+ ' "this.\$initialize(a,b,c,d" + # + ")")', |
+ functionCounter, functionCounter++); |
// It is necessary to set the constructor property, otherwise it will be |
// "Object". |
@@ -2722,12 +2723,14 @@ abstract class Closure implements Function { |
} |
if (arity == 0) { |
+ // Incorporate functionCounter into a local. |
+ String selfName = 'self${functionCounter++}'; |
return JS( |
'', |
'(new Function(#))()', |
'return function(){' |
- 'return this.${BoundClosure.selfFieldName()}.$stubName();' |
- '${functionCounter++}' |
+ 'var $selfName = this.${BoundClosure.selfFieldName()};' |
+ 'return $selfName.$stubName();' |
'}'); |
} |
assert (1 <= arity && arity < 27); |
@@ -2735,12 +2738,12 @@ abstract class Closure implements Function { |
'String', |
'"abcdefghijklmnopqrstuvwxyz".split("").splice(0,#).join(",")', |
arity); |
+ arguments += '${functionCounter++}'; |
return JS( |
'', |
'(new Function(#))()', |
'return function($arguments){' |
'return this.${BoundClosure.selfFieldName()}.$stubName($arguments);' |
- '${functionCounter++}' |
'}'); |
} |