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

Unified Diff: test/mjsunit/compiler/property-static.js

Issue 12051058: Allow monomorphic loads when static type is known. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/property-static.js
diff --git a/test/mjsunit/regress/regress-171641.js b/test/mjsunit/compiler/property-static.js
similarity index 59%
copy from test/mjsunit/regress/regress-171641.js
copy to test/mjsunit/compiler/property-static.js
index 8db6781821325f8f6253eb2df4abb2b362b001c0..07021340cd7aa94440638f925eeed921ee78c9c7 100644
--- a/test/mjsunit/regress/regress-171641.js
+++ b/test/mjsunit/compiler/property-static.js
@@ -27,14 +27,43 @@
// Flags: --allow-natives-syntax
-function foo(k, p) {
- for (var i = 0; i < 1; i++) {
- p = Math.min(p, i);
+// Test usage of static type information for loads that would otherwise
+// turn into polymorphic or generic loads.
+
+// Prepare a highly polymorphic load to be used by all tests.
+Object.prototype.load = function() { return this.property; };
+Object.prototype.load.call({ A:0, property:10 });
+Object.prototype.load.call({ A:0, B:0, property:11 });
+Object.prototype.load.call({ A:0, B:0, C:0, property:12 });
+Object.prototype.load.call({ A:0, B:0, C:0, D:0, property:13 });
+Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, property:14 });
+Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, F:0, property:15 });
+
+// Test for object literals.
+(function() {
+ function f(x) {
+ var object = { property:x };
+ return object.load();
+ }
+
+ assertSame(1, f(1));
+ assertSame(2, f(2));
+ %OptimizeFunctionOnNextCall(f);
+ assertSame(3, f(3));
+})();
+
+// Test for inlined constructors.
+(function() {
+ function c(x) {
+ this.property = x;
+ }
+ function f(x) {
+ var object = new c(x);
+ return object.load();
}
- m = Math.floor((k | 0) / p);
-}
-foo(0, 1);
-foo(0, 1);
-%OptimizeFunctionOnNextCall(foo);
-foo(0, 1);
+ assertSame(1, f(1));
+ assertSame(2, f(2));
+ %OptimizeFunctionOnNextCall(f);
+ assertSame(3, f(3));
+})();
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698