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

Unified Diff: test/mjsunit/arguments-deopt.js

Issue 2692753004: [turbofan] escape analysis supports arguments object and rest elements (Closed)
Patch Set: handle the case where Deoptimizer::function_ is a Smi Created 3 years, 10 months 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/objects.cc ('k') | test/mjsunit/compiler/rest-parameters.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/arguments-deopt.js
diff --git a/test/mjsunit/arguments-deopt.js b/test/mjsunit/arguments-deopt.js
index 0cf3c0455cbe228284152ffc1b63aa19b8ab9859..c669bb41e9ed42855a6a9be9d83e4c7d18717bdb 100644
--- a/test/mjsunit/arguments-deopt.js
+++ b/test/mjsunit/arguments-deopt.js
@@ -11,18 +11,18 @@
return x + y;
}
- function test() {
+ function test1() {
%DeoptimizeNow();
return f.apply(null, arguments);
}
- assertEquals(test(1, 2), 3);
- assertEquals(test(1, 2, 3), 3);
+ assertEquals(test1(1, 2), 3);
+ assertEquals(test1(1, 2, 3), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2, 3), 3);
+ %OptimizeFunctionOnNextCall(test1);
+ assertEquals(test1(1, 2), 3);
+ %OptimizeFunctionOnNextCall(test1);
+ assertEquals(test1(1, 2, 3), 3);
})();
(function MaterializeSloppyArguments() {
@@ -30,18 +30,18 @@
return x + y;
}
- function test() {
+ function test2() {
%DeoptimizeNow();
return f.apply(null, arguments);
}
- assertEquals(test(1, 2), 3);
- assertEquals(test(1, 2, 3), 3);
+ assertEquals(test2(1, 2), 3);
+ assertEquals(test2(1, 2, 3), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2, 3), 3);
+ %OptimizeFunctionOnNextCall(test2);
+ assertEquals(test2(1, 2), 3);
+ %OptimizeFunctionOnNextCall(test2);
+ assertEquals(test2(1, 2, 3), 3);
})();
(function MaterializeStrictOverwrittenArguments() {
@@ -51,19 +51,19 @@
return x + y;
}
- function test(a, b) {
+ function test3(a, b) {
a = 4;
%DeoptimizeNow();
return f.apply(null, arguments);
}
- assertEquals(test(1, 2), 3);
- assertEquals(test(1, 2, 3), 3);
+ assertEquals(test3(1, 2), 3);
+ assertEquals(test3(1, 2, 3), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2), 3);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2, 3), 3);
+ %OptimizeFunctionOnNextCall(test3);
+ assertEquals(test3(11, 12), 23);
+ %OptimizeFunctionOnNextCall(test3);
+ assertEquals(test3(11, 12, 13), 23);
})();
(function MaterializeSloppyOverwrittenArguments() {
@@ -71,20 +71,99 @@
return x + y;
}
- function test(a, b) {
+ function test4(a, b) {
a = 4;
%DeoptimizeNow();
return f.apply(null, arguments);
}
- test(1, 2);
- test(3, 4, 5);
+ test4(1, 2);
+ test4(3, 4, 5);
- assertEquals(test(1, 2), 6);
- assertEquals(test(1, 2, 3), 6);
+ assertEquals(test4(1, 2), 6);
+ assertEquals(test4(1, 2, 3), 6);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2), 6);
- %OptimizeFunctionOnNextCall(test);
- assertEquals(test(1, 2, 3), 6);
+ %OptimizeFunctionOnNextCall(test4);
+ assertEquals(test4(1, 2), 6);
+ %OptimizeFunctionOnNextCall(test4);
+ assertEquals(test4(1, 2, 3), 6);
+})();
+
+(function ArgumentsAccessStrict () {
+ "use strict"
+ function sum1(a,b,c) {
+ var sum = 0;
+ var rest = arguments;
+ for (var i = 0; i < rest.length; ++i) {
+ var j = i;
+ if (rest.length % 15 == 0 && i == 10) j += rest.length;
+ sum += rest[j] || rest[j-rest.length];
+ }
+ return sum;
+ };
+
+ var args = []
+ for (var i = 1; i < 30; ++i) {
+ args.push(i);
+ if (i%10 == 0) %OptimizeFunctionOnNextCall(sum1);
+ assertEquals(i*(i+1)/2, sum1(...args));
+ }
+})();
+
+(function ArgumentsAccessSloppy () {
+ function sum2(a,b,c) {
+ var sum = 0;
+ var rest = arguments;
+ for (var i = 0; i < rest.length; ++i) {
+ var j = i;
+ if (rest.length % 15 == 0 && i == 10) j += rest.length;
+ sum += rest[j] || rest[j-rest.length];
+ }
+ return sum;
+ };
+
+ var args = []
+ for (var i = 1; i < 30; ++i) {
+ args.push(i);
+ if (i%10 == 0) %OptimizeFunctionOnNextCall(sum2);
+ assertEquals(i*(i+1)/2, sum2(...args));
+ }
+})();
+
+(function RestAccess0 () {
+ function sum3(...rest) {
+ var sum = 0;
+ for (var i = 0; i < rest.length; ++i) {
+ var j = i;
+ if (rest.length % 15 == 0 && i == 10) j += rest.length;
+ sum += rest[j] || rest[j-rest.length];
+ }
+ return sum;
+ };
+
+ var args = []
+ for (var i = 1; i < 30; ++i) {
+ args.push(i);
+ if (i%10 == 0) %OptimizeFunctionOnNextCall(sum3);
+ assertEquals(i*(i+1)/2, sum3(...args));
+ }
+})();
+
+(function RestAccess1 () {
+ function sum4(a,...rest) {
+ var sum = 0;
+ for (var i = 0; i < rest.length; ++i) {
+ var j = i;
+ if (rest.length % 15 == 0 && i == 10) j += rest.length;
+ sum += rest[j] || rest[j-rest.length];
+ }
+ return sum;
+ };
+
+ var args = []
+ for (var i = 1; i < 30; ++i) {
+ args.push(i);
+ if (i%10 == 0) %OptimizeFunctionOnNextCall(sum4);
+ assertEquals(i*(i+1)/2-1, sum4(...args));
+ }
})();
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/compiler/rest-parameters.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698