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

Unified Diff: test/mjsunit/compiler/inline-arity-mismatch.js

Issue 9265004: Support inlining at call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: finished implementation, extended tests, ported to x64&arm Created 8 years, 11 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
Index: test/mjsunit/compiler/inline-arity-mismatch.js
diff --git a/test/mjsunit/compiler/regress-funarguments.js b/test/mjsunit/compiler/inline-arity-mismatch.js
similarity index 57%
copy from test/mjsunit/compiler/regress-funarguments.js
copy to test/mjsunit/compiler/inline-arity-mismatch.js
index cea40bc9bafe390293206e3dd9b02ea05ae6504b..4a61fa3a62c36f8f53b12cde023f52bdb6e1abc7 100644
--- a/test/mjsunit/compiler/regress-funarguments.js
+++ b/test/mjsunit/compiler/inline-arity-mismatch.js
@@ -1,4 +1,4 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,58 +25,38 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Test function.arguments.
+// Flags: --allow-natives-syntax
-function A() {}
-function B() {}
+// Test inlining at call sites with mismatched arity.
-function fee(x, y) {
- if (x == 1) return fee["arg" + "uments"];
- if (x == 2) return gee["arg" + "uments"];
- return 42;
+function f(a) {
+ return a.x;
}
-function gee(x) { return this.f(2 - x, "f"); }
-
-function foo(x, y) {
- if (x == 0) return foo["arg" + "uments"];
- if (x == 1) return goo["arg" + "uments"];
- return 42;
+function g(a, b) {
+ return a.x;
}
-function goo(x) { return this.f(x, "f"); }
-
-A.prototype.f = fee;
-A.prototype.g = gee;
-
-B.prototype.f = foo;
-B.prototype.g = goo;
-
-var o = new A();
-
-function hej(x) {
- if (x == 0) return o.g(x, "h");
- if (x == 1) return o.g(x, "h");
- return o.g(x, "z");
+function h1(a, b) {
+ return f(a, a) * g(b);
}
-function stress() {
- for (var i=0; i<5000000; i++) o.g(i, "g");
- for (var j=0; j<5000000; j++) hej(j);
+function h2(a, b) {
+ return f(a, a) * g(b);
}
-stress();
-
-assertArrayEquals([0, "g"], o.g(0, "g"));
-assertArrayEquals([1, "f"], o.g(1, "g"));
-assertArrayEquals([0, "h"], hej(0));
-assertArrayEquals([1, "f"], hej(1));
-o = new B();
+var o = {x: 2};
-stress();
+assertEquals(4, h1(o, o));
+assertEquals(4, h1(o, o));
+assertEquals(4, h2(o, o));
+assertEquals(4, h2(o, o));
+%OptimizeFunctionOnNextCall(h1);
+%OptimizeFunctionOnNextCall(h2);
+assertEquals(4, h1(o, o));
+assertEquals(4, h2(o, o));
-assertArrayEquals([0, "f"], o.g(0, "g"));
-assertArrayEquals([1, "g"], o.g(1, "g"));
-assertArrayEquals([0, "f"], hej(0));
-assertArrayEquals([1, "h"], hej(1));
+var u = {y:0, x:1};
+assertEquals(2, h1(u, o));
+assertEquals(2, h2(o, u));

Powered by Google App Engine
This is Rietveld 408576698