| Index: test/mjsunit/compiler/load-elimination.js
|
| diff --git a/test/mjsunit/compiler/property-static.js b/test/mjsunit/compiler/load-elimination.js
|
| similarity index 56%
|
| copy from test/mjsunit/compiler/property-static.js
|
| copy to test/mjsunit/compiler/load-elimination.js
|
| index 07021340cd7aa94440638f925eeed921ee78c9c7..e019508c65ebdc9eb08e03979f81b70633f55319 100644
|
| --- a/test/mjsunit/compiler/property-static.js
|
| +++ b/test/mjsunit/compiler/load-elimination.js
|
| @@ -25,45 +25,82 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Flags: --allow-natives-syntax
|
| +// Flags: --allow-natives-syntax --load-elimination
|
|
|
| -// Test usage of static type information for loads that would otherwise
|
| -// turn into polymorphic or generic loads.
|
| +// Test local load elimination of redundant loads and stores.
|
|
|
| -// 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 });
|
| +function B(x, y) {
|
| + this.x = x;
|
| + this.y = y;
|
| + return this;
|
| +}
|
|
|
| -// Test for object literals.
|
| -(function() {
|
| - function f(x) {
|
| - var object = { property:x };
|
| - return object.load();
|
| - }
|
| +function test_load() {
|
| + var a = new B(1, 2);
|
| + return a.x + a.x + a.x + a.x;
|
| +}
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| - %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| +function test_store_load() {
|
| + var a = new B(1, 2);
|
| + a.x = 4;
|
| + var f = a.x;
|
| + a.x = 5;
|
| + var g = a.x;
|
| + a.x = 6;
|
| + var h = a.x;
|
| + a.x = 7;
|
| + return f + g + h + a.x;
|
| +}
|
| +
|
| +function test_nonaliasing_store1() {
|
| + var a = new B(2, 3), b = new B(3, 4);
|
| + b.x = 4;
|
| + var f = a.x;
|
| + b.x = 5;
|
| + var g = a.x;
|
| + b.x = 6;
|
| + var h = a.x;
|
| + b.x = 7;
|
| + return f + g + h + a.x;
|
| +}
|
| +
|
| +function killall() {
|
| + try { } catch(e) { }
|
| +}
|
|
|
| -// Test for inlined constructors.
|
| -(function() {
|
| - function c(x) {
|
| - this.property = x;
|
| - }
|
| - function f(x) {
|
| - var object = new c(x);
|
| - return object.load();
|
| - }
|
| +%NeverOptimizeFunction(killall);
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| +function test_store_load_kill() {
|
| + var a = new B(1, 2);
|
| + a.x = 4;
|
| + var f = a.x;
|
| + a.x = 5;
|
| + var g = a.x;
|
| + killall();
|
| + a.x = 6;
|
| + var h = a.x;
|
| + a.x = 7;
|
| + return f + g + h + a.x;
|
| +}
|
| +
|
| +function test_store_store() {
|
| + var a = new B(6, 7);
|
| + a.x = 7;
|
| + a.x = 7;
|
| + a.x = 7;
|
| + a.x = 7;
|
| + return a.x;
|
| +}
|
| +
|
| +function test(x, f) {
|
| + assertEquals(x, f());
|
| + assertEquals(x, f());
|
| %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| + assertEquals(x, f());
|
| +}
|
| +
|
| +test(4, test_load);
|
| +test(22, test_store_load);
|
| +test(8, test_nonaliasing_store1);
|
| +test(22, test_store_load_kill);
|
| +test(7, test_store_store);
|
|
|