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

Side by Side 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 unified diff | Download patch
« src/parser.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-templates 5 // Flags: --harmony-templates
6 6
7 var num = 5; 7 var num = 5;
8 var str = "str"; 8 var str = "str";
9 function fn() { return "result"; } 9 function fn() { return "result"; }
10 var obj = { 10 var obj = {
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 assertEquals(1, calls); 323 assertEquals(1, calls);
324 })(); 324 })();
325 325
326 326
327 (function testUTF16ByteOrderMark() { 327 (function testUTF16ByteOrderMark() {
328 assertEquals("\uFEFFtest", `\uFEFFtest`); 328 assertEquals("\uFEFFtest", `\uFEFFtest`);
329 assertEquals("\uFEFFtest", eval("`\uFEFFtest`")); 329 assertEquals("\uFEFFtest", eval("`\uFEFFtest`"));
330 })(); 330 })();
331 331
332 332
333 (function testCallSiteCaching() {
334 var callSites = [];
335 function tag(cs) { callSites.push(cs); }
336 var a = 1;
337 var b = 2;
338
339 tag`head${a}tail`;
340 tag`head${b}tail`;
341
342 assertEquals(2, callSites.length);
343 assertSame(callSites[0], callSites[1]);
344
345 eval("tag`head${a}tail`");
346 assertEquals(3, callSites.length);
347 assertSame(callSites[1], callSites[2]);
348
349 eval("tag`head${b}tail`");
350 assertEquals(4, callSites.length);
351 assertSame(callSites[2], callSites[3]);
352
353 (new Function("tag", "a", "b", "return tag`head${a}tail`;"))(tag, 1, 2);
354 assertEquals(5, callSites.length);
355 assertSame(callSites[3], callSites[4]);
356
357 (new Function("tag", "a", "b", "return tag`head${b}tail`;"))(tag, 1, 2);
358 assertEquals(6, callSites.length);
359 assertSame(callSites[4], callSites[5]);
360
361 callSites = [];
362
363 tag`foo${a}bar`;
364 tag`foo\${.}bar`;
365 assertEquals(2, callSites[0].length);
366 assertEquals(1, callSites[1].length);
367 })();
arv (Not doing code reviews) 2014/11/19 06:09:11 Maybe a test that has same values in the array but
368
369
333 (function testExtendedArrayPrototype() { 370 (function testExtendedArrayPrototype() {
334 Object.defineProperty(Array.prototype, 0, { 371 Object.defineProperty(Array.prototype, 0, {
335 set: function() { 372 set: function() {
336 assertUnreachable(); 373 assertUnreachable();
337 } 374 }
338 }); 375 });
339 function tag(){} 376 function tag(){}
340 tag`a${1}b`; 377 tag`a${1}b`;
341 })(); 378 })();
OLDNEW
« 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