Index: test/mjsunit/compiler/compare-map-elim2.js |
diff --git a/test/mjsunit/compiler/compare_objeq_elim.js b/test/mjsunit/compiler/compare-map-elim2.js |
similarity index 52% |
rename from test/mjsunit/compiler/compare_objeq_elim.js |
rename to test/mjsunit/compiler/compare-map-elim2.js |
index 4492df45c32a5a7c0dbc25f8bb28470ff8eafcf0..0c0540ccab3b80c334127c81fee4648b4856b66e 100644 |
--- a/test/mjsunit/compiler/compare_objeq_elim.js |
+++ b/test/mjsunit/compiler/compare-map-elim2.js |
@@ -27,59 +27,104 @@ |
// Flags: --allow-natives-syntax --check-elimination |
-function A(x, y) { |
- this.x = x; |
- this.y = y; |
-} |
-function B(x, y) { |
- this.x = x; |
- this.y = y; |
-} |
+function test_empty() { |
+ function foo(o) { |
+ return { value: o.value }; |
+ } |
-function F1(a, b) { |
- if (a == b) return a.x; |
- else return b.x; |
-} |
+ function Base() { |
+ this.v_ = 5; |
+ } |
+ Base.prototype.__defineGetter__("value", function() { return 1; }); |
-function F2(a, b) { |
- if (a == b) return a.x; |
- else return b.x; |
-} |
+ var a = new Base(); |
+ a.a = 1; |
+ foo(a); |
-function F3(a, b) { |
- var f = a.y; |
- if (a == b) return a.x; |
- else return b.x; |
-} |
+ Base.prototype.__defineGetter__("value", function() { return this.v_; }); |
+ |
+ var b = new Base(); |
+ b.b = 1; |
+ foo(b); |
-function F4(a, b) { |
- var f = b.y; |
- if (a == b) return a.x; |
- else return b.x; |
+ var d = new Base(); |
+ d.d = 1; |
+ d.value; |
+ |
+ %OptimizeFunctionOnNextCall(foo); |
+ |
+ var o = foo(b); |
} |
-%NeverOptimizeFunction(test); |
-function test(f, a, b) { |
- f(a, a); |
- f(a, b); |
- f(b, a); |
- f(b, c); |
- f(b, b); |
- f(c, c); |
+function test_narrow1() { |
+ function foo(o) { |
+ return { value: o.value }; |
+ } |
+ |
+ function Base() { |
+ this.v_ = 5; |
+ } |
+ Base.prototype.__defineGetter__("value", function() { return 1; }); |
+ |
+ var a = new Base(); |
+ a.a = 1; |
+ foo(a); |
+ |
+ Base.prototype.__defineGetter__("value", function() { return this.v_; }); |
+ |
+ var b = new Base(); |
+ b.b = 1; |
+ foo(b); |
- %OptimizeFunctionOnNextCall(f) |
+ var c = new Base(); |
+ c.c = 1; |
+ foo(c); |
- assertEquals(a.x, f(a, a)); |
- assertEquals(b.x, f(b, b)); |
+ var d = new Base(); |
+ d.d = 1; |
+ d.value; |
+ |
+ %OptimizeFunctionOnNextCall(foo); |
+ |
+ var o = foo(b); |
} |
-var a = new A(3, 5); |
-var b = new B(2, 6); |
-var c = new A(1, 7); |
-test(F1, a, c); |
-test(F2, a, b); |
-test(F3, a, b); |
-test(F4, a, b); |
+function test_narrow2() { |
+ function foo(o, flag) { |
+ return { value: o.value(flag) }; |
+ } |
+ |
+ function Base() { |
+ this.v_ = 5; |
+ } |
+ Base.prototype.value = function(flag) { return flag ? this.v_ : this.v_; }; |
+ |
+ |
+ var a = new Base(); |
+ a.a = 1; |
+ foo(a, false); |
+ foo(a, false); |
+ |
+ var b = new Base(); |
+ b.b = 1; |
+ foo(b, true); |
+ |
+ var c = new Base(); |
+ c.c = 1; |
+ foo(c, true); |
+ |
+ var d = new Base(); |
+ d.d = 1; |
+ d.value(true); |
+ |
+ %OptimizeFunctionOnNextCall(foo); |
+ |
+ var o = foo(b); |
+} |
+ |
+test_empty(); |
+test_narrow1(); |
+test_narrow2(); |