OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 obj["x" + i] = 0; | 43 obj["x" + i] = 0; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 function DoProtoMagic(proto, set__proto__) { | 48 function DoProtoMagic(proto, set__proto__) { |
49 if (set__proto__) { | 49 if (set__proto__) { |
50 (new Sub()).__proto__ = proto; | 50 (new Sub()).__proto__ = proto; |
51 } else { | 51 } else { |
52 Sub.prototype = proto; | 52 Sub.prototype = proto; |
53 // Need to instantiate Sub to mark .prototype as prototype. | 53 // Need to instantiate Sub to mark .prototype as prototype. Make sure the |
54 new Sub(); | 54 // instantiated object is used so that the allocation is not optimized away. |
| 55 %DebugPrint(new Sub()); |
55 } | 56 } |
56 } | 57 } |
57 | 58 |
58 | 59 |
59 function test(use_new, add_first, set__proto__) { | 60 function test(use_new, add_first, set__proto__) { |
60 var proto = use_new ? new Super() : {}; | 61 var proto = use_new ? new Super() : {}; |
61 | 62 |
62 // New object is fast. | 63 // New object is fast. |
63 assertTrue(%HasFastProperties(proto)); | 64 assertTrue(%HasFastProperties(proto)); |
64 | 65 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 assertTrue(key == 'a'); | 105 assertTrue(key == 'a'); |
105 break; | 106 break; |
106 } | 107 } |
107 assertTrue(%HasFastProperties(x)); | 108 assertTrue(%HasFastProperties(x)); |
108 x.d = 4; | 109 x.d = 4; |
109 assertTrue(%HasFastProperties(x)); | 110 assertTrue(%HasFastProperties(x)); |
110 for (key in x) { | 111 for (key in x) { |
111 assertTrue(key == 'a'); | 112 assertTrue(key == 'a'); |
112 break; | 113 break; |
113 } | 114 } |
OLD | NEW |