1014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// Copyright 2015 the V8 project authors. All rights reserved. 2014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// found in the LICENSE file. 4014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 5014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch// Flags: --allow-natives-syntax 6014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch 7014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochfunction broken(value) { 8014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return Math.floor(value/65536); 9014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 10014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochfunction toUnsigned(i) { 11014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return i >>> 0; 12014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 13014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochfunction outer(i) { 14014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch return broken(toUnsigned(i)); 15014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch} 16014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochfor (var i = 0; i < 5; i++) outer(0); 17014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdochbroken(0x80000000); // Spice things up with a sprinkling of type feedback. 18014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben Murdoch%OptimizeFunctionOnNextCall(outer); 19014dc512cdd3e367bee49a713fdc5ed92584a3e5Ben MurdochassertEquals(32768, outer(0x80000000)); 20