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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 function C() { | 38 function C() { |
39 } | 39 } |
40 | 40 |
41 function test_load() { | 41 function test_load() { |
42 var a = new B(1, 2); | 42 var a = new B(1, 2); |
43 return a.x + a.x + a.x + a.x; | 43 return a.x + a.x + a.x + a.x; |
44 } | 44 } |
45 | 45 |
| 46 |
| 47 function test_load_from_different_contexts() { |
| 48 var r = 1; |
| 49 this.f = function() { |
| 50 var fr = r; |
| 51 this.g = function(flag) { |
| 52 var gr; |
| 53 if (flag) { |
| 54 gr = r; |
| 55 } else { |
| 56 gr = r; |
| 57 } |
| 58 return gr + r + fr; |
| 59 }; |
| 60 }; |
| 61 this.f(); |
| 62 return this.g(true); |
| 63 } |
| 64 |
| 65 |
46 function test_store_load() { | 66 function test_store_load() { |
47 var a = new B(1, 2); | 67 var a = new B(1, 2); |
48 a.x = 4; | 68 a.x = 4; |
49 var f = a.x; | 69 var f = a.x; |
50 a.x = 5; | 70 a.x = 5; |
51 var g = a.x; | 71 var g = a.x; |
52 a.x = 6; | 72 a.x = 6; |
53 var h = a.x; | 73 var h = a.x; |
54 a.x = 7; | 74 a.x = 7; |
55 return f + g + h + a.x; | 75 return f + g + h + a.x; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 141 } |
122 | 142 |
123 function test(x, f) { | 143 function test(x, f) { |
124 assertEquals(x, f()); | 144 assertEquals(x, f()); |
125 assertEquals(x, f()); | 145 assertEquals(x, f()); |
126 %OptimizeFunctionOnNextCall(f); | 146 %OptimizeFunctionOnNextCall(f); |
127 assertEquals(x, f()); | 147 assertEquals(x, f()); |
128 } | 148 } |
129 | 149 |
130 test(4, test_load); | 150 test(4, test_load); |
| 151 test(3, new test_load_from_different_contexts().g); |
131 test(22, test_store_load); | 152 test(22, test_store_load); |
132 test(8, test_nonaliasing_store1); | 153 test(8, test_nonaliasing_store1); |
133 test(5, test_transitioning_store1); | 154 test(5, test_transitioning_store1); |
134 test(4, test_transitioning_store2); | 155 test(4, test_transitioning_store2); |
135 test(20, test_transitioning_store3); | 156 test(20, test_transitioning_store3); |
136 test(22, test_store_load_kill); | 157 test(22, test_store_load_kill); |
137 test(7, test_store_store); | 158 test(7, test_store_store); |
OLD | NEW |