1e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// Copyright 2013 the V8 project authors. All rights reserved. 2e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// Redistribution and use in source and binary forms, with or without 3e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// modification, are permitted provided that the following conditions are 4e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// met: 5e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// 6e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// * Redistributions of source code must retain the above copyright 7e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// notice, this list of conditions and the following disclaimer. 8e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// * Redistributions in binary form must reproduce the above 9e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// copyright notice, this list of conditions and the following 10e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// disclaimer in the documentation and/or other materials provided 11e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// with the distribution. 12e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// * Neither the name of Google Inc. nor the names of its 13e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// contributors may be used to endorse or promote products derived 14e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// from this software without specific prior written permission. 15e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// 16e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org 28e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// Flags: --allow-natives-syntax --dead-code-elimination 29e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org 30e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// This tests that stores on captured objects are correctly tracked even 31e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// when DCE is enabled. We cannot delete simulations of captured objects 32e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org// that are still needed to replay the environment correctly. 33e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org 34e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgfunction constructor() { 35e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org this.x = 0; 36e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org} 37e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org 38e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgvar deopt = { deopt:false }; 39e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgfunction boogeyman(mode, value) { 40e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org var object = new constructor(); 41e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org if (mode) { 42e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org object.x = 1; 43e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org } else { 44e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org object.x = 2; 45e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org } 46e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org deopt.deopt; 47e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org assertEquals(value, object.x); 48e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org} 49e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org 50e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(true, 1); 51e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(true, 1); 52e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(false, 2); 53e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(false, 2); 54e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.org%OptimizeFunctionOnNextCall(boogeyman); 55e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(false, 2); 56e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgdelete deopt.deopt; 57e8412be858dc48afaec4959e42c5932f71a7f29bmachenbach@chromium.orgboogeyman(false, 2); 58