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

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: 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
« src/parser.cc ('K') | « 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 15ad9e92ca889762ce125cf05a3c811fad92a5f2..d86d26312e88d5dab65b4a7303de1538ea43d255 100644
--- a/test/mjsunit/harmony/templates.js
+++ b/test/mjsunit/harmony/templates.js
@@ -330,6 +330,43 @@ 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[0].length);
+ assertEquals(1, callSites[1].length);
+})();
arv (Not doing code reviews) 2014/11/19 06:09:11 Maybe a test that has same values in the array but
+
+
(function testExtendedArrayPrototype() {
Object.defineProperty(Array.prototype, 0, {
set: function() {
« src/parser.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698