Index: test/mjsunit/compiler/stubs/floor-stub.js |
diff --git a/test/mjsunit/regress/regress-3976.js b/test/mjsunit/compiler/stubs/floor-stub.js |
similarity index 58% |
copy from test/mjsunit/regress/regress-3976.js |
copy to test/mjsunit/compiler/stubs/floor-stub.js |
index efa3ac03bc05a5b1018eb1bdd0db761154f2b664..98932208f36af98dc72d28de0c69aa7d712d35c1 100644 |
--- a/test/mjsunit/regress/regress-3976.js |
+++ b/test/mjsunit/compiler/stubs/floor-stub.js |
@@ -25,56 +25,29 @@ |
// (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-old-space-size=60 --check-handle-count |
+// Flags: --allow-natives-syntax --expose-natives-as=builtins --noalways-opt |
-table = []; |
+const kExtraTypeFeedbackMinusZeroSentinel = 1; |
+const kFirstSlotExtraTypeFeedbackIndex = 5; |
-for (var i = 0; i < 32; i++) { |
- table[i] = String.fromCharCode(i + 0x410); |
-} |
- |
- |
-var random = (function() { |
- var seed = 10; |
- return function() { |
- seed = (seed * 1009) % 8831; |
- return seed; |
- }; |
-})(); |
- |
- |
-function key(length) { |
- var s = ""; |
- for (var i = 0; i < length; i++) { |
- s += table[random() % 32]; |
- } |
- return '"' + s + '"'; |
-} |
- |
- |
-function value() { |
- return '[{' + '"field1" : ' + random() + ', "field2" : ' + random() + '}]'; |
-} |
- |
- |
-function generate(n) { |
- var s = '{'; |
- for (var i = 0; i < n; i++) { |
- if (i > 0) s += ', '; |
- s += key(random() % 10 + 7); |
- s += ':'; |
- s += value(); |
+(function(){ |
+ var floorFunc = function() { |
+ Math.floor(NaN); |
} |
- s += '}'; |
- return s; |
-} |
- |
- |
-print("generating"); |
- |
-var str = generate(50000); |
- |
-print("parsing " + str.length); |
-JSON.parse(str); |
- |
-print("done"); |
+ // Execute the function once to make sure it has a type feedback vector. |
+ floorFunc(5); |
+ assertTrue(kExtraTypeFeedbackMinusZeroSentinel !== |
+ %FixedArrayGet(%GetTypeFeedbackVector(floorFunc), |
+ kFirstSlotExtraTypeFeedbackIndex)); |
+ assertEquals(5.0, builtins.MathFloor_STUB(floorFunc, 4, 5.5)); |
+ assertTrue(kExtraTypeFeedbackMinusZeroSentinel !== |
+ %FixedArrayGet(%GetTypeFeedbackVector(floorFunc), |
+ kFirstSlotExtraTypeFeedbackIndex)); |
+ // Executing floor such that it returns -0 should set the proper sentinel in |
+ // the feedback vector. |
+ assertEquals(-Infinity, 1/builtins.MathFloor_STUB(floorFunc, 4, -0)); |
+ assertEquals(kExtraTypeFeedbackMinusZeroSentinel, |
+ %FixedArrayGet(%GetTypeFeedbackVector(floorFunc), |
+ kFirstSlotExtraTypeFeedbackIndex)); |
+ %ClearFunctionTypeFeedback(floorFunc); |
+})(); |