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)); |
+})(); |