From f7a39a62411fa93fc45d37970db1c4b9f79a46f8 Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Thu, 5 Nov 2015 10:36:06 -0800 Subject: [PATCH] Side effect characterization of String.fromCharCode This allows dart2js to determine 'Primitive_stringFromCharCode' is effect free. BUG= R=floitsch@google.com Review URL: https://codereview.chromium.org/1420273011 . --- sdk/lib/_internal/js_runtime/lib/js_helper.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart index 2490448ff80..20ac448df5f 100644 --- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart +++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart @@ -1017,13 +1017,15 @@ class Primitives { static String stringFromCharCode(charCode) { if (0 <= charCode) { if (charCode <= 0xffff) { - return JS('String', 'String.fromCharCode(#)', charCode); + return JS('returns:String;effects:none;depends:none', + 'String.fromCharCode(#)', charCode); } if (charCode <= 0x10ffff) { var bits = charCode - 0x10000; var low = 0xDC00 | (bits & 0x3ff); var high = 0xD800 | (bits >> 10); - return JS('String', 'String.fromCharCode(#, #)', high, low); + return JS('returns:String;effects:none;depends:none', + 'String.fromCharCode(#, #)', high, low); } } throw new RangeError.range(charCode, 0, 0x10ffff);