| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 caught = true; | 49 caught = true; |
| 50 } | 50 } |
| 51 assertTrue(caught); | 51 assertTrue(caught); |
| 52 | 52 |
| 53 | 53 |
| 54 // Test monomorphic case. | 54 // Test monomorphic case. |
| 55 function g(o) { | 55 function g(o) { |
| 56 return o.x(); | 56 return o.x(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 function O(x) { this.x = x; }; | 59 function O(x) { this.x = x; } |
| 60 var o = new O(function() { return 1; }); | 60 var o = new O(function() { return 1; }); |
| 61 assertEquals(1, g(o)); // go monomorphic | 61 assertEquals(1, g(o)); // go monomorphic |
| 62 assertEquals(1, g(o)); // stay monomorphic | 62 assertEquals(1, g(o)); // stay monomorphic |
| 63 | 63 |
| 64 var caught = false; | 64 var caught = false; |
| 65 try { | 65 try { |
| 66 g(new O(3)); | 66 g(new O(3)); |
| 67 } catch (o) { | 67 } catch (o) { |
| 68 assertTrue(o instanceof TypeError); | 68 assertTrue(o instanceof TypeError); |
| 69 caught = true; | 69 caught = true; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 assertEquals(3, f({ x: function () { return 3; }})); // stay megamorphic | 81 assertEquals(3, f({ x: function () { return 3; }})); // stay megamorphic |
| 82 | 82 |
| 83 var caught = false; | 83 var caught = false; |
| 84 try { | 84 try { |
| 85 f({ x: 4 }); | 85 f({ x: 4 }); |
| 86 } catch (o) { | 86 } catch (o) { |
| 87 assertTrue(o instanceof TypeError); | 87 assertTrue(o instanceof TypeError); |
| 88 caught = true; | 88 caught = true; |
| 89 } | 89 } |
| 90 assertTrue(caught); | 90 assertTrue(caught); |
| OLD | NEW |