From 840e31a0b3fa29f0166e730a933fe3b9876fda92 Mon Sep 17 00:00:00 2001 From: "ricow@chromium.org" Date: Fri, 24 Jun 2011 07:46:57 +0000 Subject: [PATCH] Add regression test for optimized version of Math.abs. This issue was already fixed on bleeding edge, but adding regression test to get coverage and to make sure it works on the branches. Review URL: http://codereview.chromium.org/7237022 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8402 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/mjsunit/math-abs.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/mjsunit/math-abs.js b/test/mjsunit/math-abs.js index 33df6f4..2b07954 100644 --- a/test/mjsunit/math-abs.js +++ b/test/mjsunit/math-abs.js @@ -25,7 +25,7 @@ // (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: --max-new-space-size=256 +// Flags: --max-new-space-size=256 --allow-natives-syntax function zero() { var x = 0.5; @@ -96,3 +96,16 @@ function test() { for (var i = 0; i < 500; i++) { test(); } + +// Regression test for optimized version of Math.abs, see: +// http://codereview.chromium.org/6875002. +function foo(x) { + return Math.abs(x); +} +// Get some smi type feedback. +for(var i = 0; i < 1000; i++) { + foo(-i); +} +assertEquals(42, foo(-42)); +%OptimizeFunctionOnNextCall(foo) +assertEquals(42, foo(-42)); -- 2.7.4