| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 21 matching lines...) Expand all Loading... |
| 32 o.x = true; | 32 o.x = true; |
| 33 delete o.x; // slow case object | 33 delete o.x; // slow case object |
| 34 | 34 |
| 35 var u = { x: 0, f: function () { return "u"; } }; // object with some other map | 35 var u = { x: 0, f: function () { return "u"; } }; // object with some other map |
| 36 | 36 |
| 37 function F(x) { | 37 function F(x) { |
| 38 return x.f(); | 38 return x.f(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // First make CALL IC in F go MEGAMORPHIC and ensure that we put the stub | 41 // First make CALL IC in F go MEGAMORPHIC and ensure that we put the stub |
| 42 // that calls p.f (guarded by a negative dictionary lookup on the reciever) | 42 // that calls p.f (guarded by a negative dictionary lookup on the receiver) |
| 43 // into the stub cache | 43 // into the stub cache |
| 44 assertEquals("p", F(o)); | 44 assertEquals("p", F(o)); |
| 45 assertEquals("p", F(o)); | 45 assertEquals("p", F(o)); |
| 46 assertEquals("u", F(u)); | 46 assertEquals("u", F(u)); |
| 47 assertEquals("p", F(o)); | 47 assertEquals("p", F(o)); |
| 48 assertEquals("u", F(u)); | 48 assertEquals("u", F(u)); |
| 49 | 49 |
| 50 // Optimize F. We will inline p.f into F guarded by map checked against | 50 // Optimize F. We will inline p.f into F guarded by map checked against |
| 51 // receiver which does not work for slow case objects. | 51 // receiver which does not work for slow case objects. |
| 52 %OptimizeFunctionOnNextCall(F); | 52 %OptimizeFunctionOnNextCall(F); |
| 53 assertEquals("p", F(o)); | 53 assertEquals("p", F(o)); |
| 54 | 54 |
| 55 // Add f to o. o's map will *not* change. | 55 // Add f to o. o's map will *not* change. |
| 56 o.f = function () { return "o"; }; | 56 o.f = function () { return "o"; }; |
| 57 assertEquals("o", F(o)); | 57 assertEquals("o", F(o)); |
| OLD | NEW |