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

Unified Diff: test/mjsunit/harmony/templates.js

Issue 742643003: Cache template literal callSiteObj (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ensure hash is a valid Smi literal Created 6 years, 1 month 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 | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/templates.js
diff --git a/test/mjsunit/harmony/templates.js b/test/mjsunit/harmony/templates.js
index 7c63ec968cc8b1fd36e358a1863732a50bbdf9db..3baf05eb5d0583734e09a4896663f49119742438 100644
--- a/test/mjsunit/harmony/templates.js
+++ b/test/mjsunit/harmony/templates.js
@@ -338,6 +338,75 @@ var obj = {
})();
+(function testCallSiteCaching() {
+ var callSites = [];
+ function tag(cs) { callSites.push(cs); }
+ var a = 1;
+ var b = 2;
+
+ tag`head${a}tail`;
+ tag`head${b}tail`;
+
+ assertEquals(2, callSites.length);
+ assertSame(callSites[0], callSites[1]);
+
+ eval("tag`head${a}tail`");
+ assertEquals(3, callSites.length);
+ assertSame(callSites[1], callSites[2]);
+
+ eval("tag`head${b}tail`");
+ assertEquals(4, callSites.length);
+ assertSame(callSites[2], callSites[3]);
+
+ (new Function("tag", "a", "b", "return tag`head${a}tail`;"))(tag, 1, 2);
+ assertEquals(5, callSites.length);
+ assertSame(callSites[3], callSites[4]);
+
+ (new Function("tag", "a", "b", "return tag`head${b}tail`;"))(tag, 1, 2);
+ assertEquals(6, callSites.length);
+ assertSame(callSites[4], callSites[5]);
+
+ callSites = [];
+
+ tag`foo${a}bar`;
+ tag`foo\${.}bar`;
+ assertEquals(2, callSites.length);
+ assertEquals(2, callSites[0].length);
+ assertEquals(1, callSites[1].length);
+
+ callSites = [];
+
+ eval("tag`\\\r\n\\\n\\\r`");
+ eval("tag`\\\r\n\\\n\\\r`");
+ assertEquals(2, callSites.length);
+ assertSame(callSites[0], callSites[1]);
+ assertEquals("", callSites[0][0]);
+ assertEquals("\\\n\\\n\\\n", callSites[0].raw[0]);
+
+ callSites = [];
+
+ tag`\uc548\ub155`;
+ tag`\uc548\ub155`;
+ assertEquals(2, callSites.length);
+ assertSame(callSites[0], callSites[1]);
+ assertEquals("안녕", callSites[0][0]);
+ assertEquals("\\uc548\\ub155", callSites[0].raw[0]);
+
+ callSites = [];
+
+ tag`\uc548\ub155`;
+ tag`안녕`;
+ assertEquals(2, callSites.length);
+ assertTrue(callSites[0] !== callSites[1]);
+ assertEquals("안녕", callSites[0][0]);
+ assertEquals("\\uc548\\ub155", callSites[0].raw[0]);
+ assertEquals("안녕", callSites[1][0]);
+ // TODO(caitp, arv): blocked on correctly generating raw strings from
+ // multi-byte UTF8.
+ // assertEquals("안녕", callSites[1].raw[0]);
+})();
+
+
(function testExtendedArrayPrototype() {
Object.defineProperty(Array.prototype, 0, {
set: function() {
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698