Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 5 | // Flags: --allow-natives-syntax |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 6 | |
| 7 | function le(a, b) { |
| 8 | return a <= b; |
| 9 | } |
| 10 | |
| 11 | function lt(a, b) { |
| 12 | return a < b; |
| 13 | } |
| 14 | |
| 15 | function ge(a, b) { |
| 16 | return a >= b; |
| 17 | } |
| 18 | |
| 19 | function gt(a, b) { |
| 20 | return a > b; |
| 21 | } |
| 22 | |
| 23 | function test(a, b) { |
| 24 | // Check CompareIC for less than or equal of known objects. |
| 25 | assertThrows(function() {le(a, a)}); |
| 26 | assertThrows(function() {le(a, b)}); |
| 27 | assertThrows(function() {le(b, a)}); |
| 28 | // Check CompareIC for less than of known objects. |
| 29 | assertThrows(function() {lt(a, a)}); |
| 30 | assertThrows(function() {lt(a, b)}); |
| 31 | assertThrows(function() {lt(b, a)}); |
| 32 | // Check CompareIC for greater than or equal of known objects. |
| 33 | assertThrows(function() {ge(a, a)}); |
| 34 | assertThrows(function() {ge(a, b)}); |
| 35 | assertThrows(function() {ge(b, a)}); |
| 36 | // Check CompareIC for greater than of known objects. |
| 37 | assertThrows(function() {gt(a, a)}); |
| 38 | assertThrows(function() {gt(a, b)}); |
| 39 | assertThrows(function() {gt(b, a)}); |
| 40 | } |
| 41 | |
| 42 | function O() { } |
| 43 | Object.defineProperty(O.prototype, Symbol.toStringTag, { |
| 44 | get: function() { throw "@@toStringTag called!" } |
| 45 | }); |
| 46 | |
| 47 | var obj1 = new O; |
| 48 | var obj2 = new O; |
| 49 | |
| 50 | assertTrue(%HaveSameMap(obj1, obj2)); |
| 51 | test(obj1, obj2); |
| 52 | test(obj1, obj2); |
| 53 | %OptimizeFunctionOnNextCall(le); |
| 54 | %OptimizeFunctionOnNextCall(lt); |
| 55 | %OptimizeFunctionOnNextCall(ge); |
| 56 | %OptimizeFunctionOnNextCall(gt); |
| 57 | test(obj1, obj2); |