17ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// Copyright 2011 the V8 project authors. All rights reserved. 27ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// Redistribution and use in source and binary forms, with or without 37ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// modification, are permitted provided that the following conditions are 47ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// met: 57ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// 67ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// * Redistributions of source code must retain the above copyright 77ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// notice, this list of conditions and the following disclaimer. 87ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// * Redistributions in binary form must reproduce the above 97ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// copyright notice, this list of conditions and the following 107ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// disclaimer in the documentation and/or other materials provided 117ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// with the distribution. 127ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// * Neither the name of Google Inc. nor the names of its 137ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// contributors may be used to endorse or promote products derived 147ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// from this software without specific prior written permission. 157ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// 167ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 267ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 287ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org// Flags: --allow-natives-syntax 297ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 307ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.orgvar fn = function fn(val) { 317ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org if (val) return val; 327ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 337ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org %OptimizeFunctionOnNextCall(fn); 347ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 357ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org function run(val) { 367ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org var res = fn((val + 1) << 1); 377ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 387ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org return res; 397ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org } 407ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 417ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org return run(0); 427ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org} 437ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.org 447ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.orgvar res = fn(); 457ad65226b3ba6f9250a5ee869ee77e2b9258fc91ricow@chromium.orgassertEquals(res, 2); 46