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

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

Issue 2664423003: [turbofan] fix wrong materialization of arguments object (Closed)
Patch Set: merged test files 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/compiler/js-call-reducer.cc ('k') | no next file » | 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
new file mode 100644
index 0000000000000000000000000000000000000000..0cf3c0455cbe228284152ffc1b63aa19b8ab9859
--- /dev/null
+++ b/test/mjsunit/arguments-deopt.js
@@ -0,0 +1,90 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --turbo
+
+(function MaterializeStrictArguments() {
+ "use strict"
+
+ function f(x, y) {
+ return x + y;
+ }
+
+ function test() {
+ %DeoptimizeNow();
+ return f.apply(null, arguments);
+ }
+
+ assertEquals(test(1, 2), 3);
+ assertEquals(test(1, 2, 3), 3);
+
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2), 3);
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2, 3), 3);
+})();
+
+(function MaterializeSloppyArguments() {
+ function f(x, y) {
+ return x + y;
+ }
+
+ function test() {
+ %DeoptimizeNow();
+ return f.apply(null, arguments);
+ }
+
+ assertEquals(test(1, 2), 3);
+ assertEquals(test(1, 2, 3), 3);
+
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2), 3);
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2, 3), 3);
+})();
+
+(function MaterializeStrictOverwrittenArguments() {
+ "use strict"
+
+ function f(x, y) {
+ return x + y;
+ }
+
+ function test(a, b) {
+ a = 4;
+ %DeoptimizeNow();
+ return f.apply(null, arguments);
+ }
+
+ assertEquals(test(1, 2), 3);
+ assertEquals(test(1, 2, 3), 3);
+
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2), 3);
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2, 3), 3);
+})();
+
+(function MaterializeSloppyOverwrittenArguments() {
+ function f(x, y) {
+ return x + y;
+ }
+
+ function test(a, b) {
+ a = 4;
+ %DeoptimizeNow();
+ return f.apply(null, arguments);
+ }
+
+ test(1, 2);
+ test(3, 4, 5);
+
+ assertEquals(test(1, 2), 6);
+ assertEquals(test(1, 2, 3), 6);
+
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2), 6);
+ %OptimizeFunctionOnNextCall(test);
+ assertEquals(test(1, 2, 3), 6);
+})();
« no previous file with comments | « src/compiler/js-call-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698