| Index: test/mjsunit/compiler/load-elimination-osr.js
|
| diff --git a/test/mjsunit/regress/regress-crbug-260345.js b/test/mjsunit/compiler/load-elimination-osr.js
|
| similarity index 66%
|
| copy from test/mjsunit/regress/regress-crbug-260345.js
|
| copy to test/mjsunit/compiler/load-elimination-osr.js
|
| index 75832ab4beb9e004dda914ffc2e23647f57ef979..a57fe173ee7be04313ca7ea2c18229e23fa16375 100644
|
| --- a/test/mjsunit/regress/regress-crbug-260345.js
|
| +++ b/test/mjsunit/compiler/load-elimination-osr.js
|
| @@ -25,35 +25,41 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -var steps = 100000;
|
| -var undefined_values = [undefined, "go on"];
|
| -var null_values = [null, "go on"];
|
| +// Flags: --allow-natives-syntax --load-elimination
|
|
|
| -function get_undefined_object(i) {
|
| - return undefined_values[(i / steps) | 0];
|
| -}
|
| +// Test global load elimination in the presence of OSR compilation.
|
| +
|
| +function It(x, y) { }
|
|
|
| -function test_undefined() {
|
| - var objects = 0;
|
| - for (var i = 0; i < 2 * steps; i++) {
|
| - undefined == get_undefined_object(i) && objects++;
|
| +function foo_osr(x, limit) {
|
| + var o = new It();
|
| + o.x = x;
|
| + o.y = x;
|
| + for (var i = 0; i < limit; i++) {
|
| + o.y += o.x; // Load of x cannot be hoisted due to OSR.
|
| }
|
| - return objects;
|
| -}
|
|
|
| -assertEquals(steps, test_undefined());
|
| + return o.y;
|
| +}
|
|
|
| +assertEquals(22, foo_osr(11, 1));
|
| +assertEquals(24, foo_osr(12, 1));
|
| +assertEquals(1300013, foo_osr(13, 100000));
|
|
|
| -function get_null_object(i) {
|
| - return null_values[(i / steps) | 0];
|
| -}
|
|
|
| -function test_null() {
|
| - var objects = 0;
|
| - for (var i = 0; i < 2 * steps; i++) {
|
| - null == get_null_object(i) && objects++;
|
| +function foo_hot(x, limit) {
|
| + var o = new It();
|
| + o.x = x;
|
| + o.y = x;
|
| + for (var i = 0; i < limit; i++) {
|
| + o.y += o.x; // Load of x can be hoisted without OSR.
|
| }
|
| - return objects;
|
| +
|
| + return o.y;
|
| }
|
|
|
| -assertEquals(steps, test_null());
|
| +assertEquals(22, foo_hot(11, 1));
|
| +assertEquals(24, foo_hot(12, 1));
|
| +%OptimizeFunctionOnNextCall(foo_hot);
|
| +assertEquals(32, foo_hot(16, 1));
|
| +assertEquals(1300013, foo_hot(13, 100000));
|
|
|