| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 function testDoubleConversion4(a) { | 51 function testDoubleConversion4(a) { |
| 52 var object = new Object(); | 52 var object = new Object(); |
| 53 a[0] = 0; | 53 a[0] = 0; |
| 54 var count = 3; | 54 var count = 3; |
| 55 do { | 55 do { |
| 56 a[0] = object; | 56 a[0] = object; |
| 57 } while (--count > 0); | 57 } while (--count > 0); |
| 58 } | 58 } |
| 59 | 59 |
| 60 testDoubleConversion4(new Array(5)); | 60 testDoubleConversion4(new Array(5)); |
| 61 testDoubleConversion4(new Array(5)); |
| 61 %OptimizeFunctionOnNextCall(testDoubleConversion4); | 62 %OptimizeFunctionOnNextCall(testDoubleConversion4); |
| 62 testDoubleConversion4(new Array(5)); | 63 testDoubleConversion4(new Array(5)); |
| 63 testDoubleConversion4(new Array(5)); | 64 testDoubleConversion4(new Array(5)); |
| 64 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); | 65 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); |
| 65 | 66 |
| 66 // Make sure that non-element related map checks that are not preceded by | 67 // Make sure that non-element related map checks that are not preceded by |
| 67 // transitions in a loop still get hoisted in a way that doesn't generate a | 68 // transitions in a loop still get hoisted in a way that doesn't generate a |
| 68 // deopt in simple cases. | 69 // deopt in simple cases. |
| 69 function testExactMapHoisting(a) { | 70 function testExactMapHoisting(a) { |
| 70 var object = new Object(); | 71 var object = new Object(); |
| 71 a.foo = 0; | 72 a.foo = 0; |
| 72 a[0] = 0; | 73 a[0] = 0; |
| 73 a[1] = 1; | 74 a[1] = 1; |
| 74 var count = 3; | 75 var count = 3; |
| 75 do { | 76 do { |
| 76 a.foo = object; // This map check should be hoistable | 77 a.foo = object; // This map check should be hoistable |
| 77 a[1] = object; | 78 a[1] = object; |
| 78 result = a.foo == object && a[1] == object; | 79 result = a.foo == object && a[1] == object; |
| 79 } while (--count > 0); | 80 } while (--count > 0); |
| 80 } | 81 } |
| 81 | 82 |
| 82 testExactMapHoisting(new Array(5)); | 83 testExactMapHoisting(new Array(5)); |
| 84 testExactMapHoisting(new Array(5)); |
| 83 %OptimizeFunctionOnNextCall(testExactMapHoisting); | 85 %OptimizeFunctionOnNextCall(testExactMapHoisting); |
| 84 testExactMapHoisting(new Array(5)); | 86 testExactMapHoisting(new Array(5)); |
| 85 testExactMapHoisting(new Array(5)); | 87 testExactMapHoisting(new Array(5)); |
| 86 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); | 88 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); |
| 87 | 89 |
| 88 // Make sure that non-element related map checks do NOT get hoisted if they | 90 // Make sure that non-element related map checks do NOT get hoisted if they |
| 89 // depend on an elements transition before them and it's not possible to hoist | 91 // depend on an elements transition before them and it's not possible to hoist |
| 90 // that transition. | 92 // that transition. |
| 91 function testExactMapHoisting2(a) { | 93 function testExactMapHoisting2(a) { |
| 92 var object = new Object(); | 94 var object = new Object(); |
| 93 a.foo = 0; | 95 a.foo = 0; |
| 94 a[0] = 0; | 96 a[0] = 0; |
| 95 a[1] = 1; | 97 a[1] = 1; |
| 96 var count = 3; | 98 var count = 3; |
| 97 do { | 99 do { |
| 98 if (a.bar === undefined) { | 100 if (a.bar === undefined) { |
| 99 a[1] = 2.5; | 101 a[1] = 2.5; |
| 100 } | 102 } |
| 101 a.foo = object; // This map check should NOT be hoistable because it | 103 a.foo = object; // This map check should NOT be hoistable because it |
| 102 // includes a check for the FAST_ELEMENTS map as well as | 104 // includes a check for the FAST_ELEMENTS map as well as |
| 103 // the FAST_DOUBLE_ELEMENTS map, which depends on the | 105 // the FAST_DOUBLE_ELEMENTS map, which depends on the |
| 104 // double transition above in the if, which cannot be | 106 // double transition above in the if, which cannot be |
| 105 // hoisted. | 107 // hoisted. |
| 106 } while (--count > 0); | 108 } while (--count > 0); |
| 107 } | 109 } |
| 108 | 110 |
| 109 testExactMapHoisting2(new Array(5)); | 111 testExactMapHoisting2(new Array(5)); |
| 112 testExactMapHoisting2(new Array(5)); |
| 110 %OptimizeFunctionOnNextCall(testExactMapHoisting2); | 113 %OptimizeFunctionOnNextCall(testExactMapHoisting2); |
| 111 testExactMapHoisting2(new Array(5)); | 114 testExactMapHoisting2(new Array(5)); |
| 112 testExactMapHoisting2(new Array(5)); | 115 testExactMapHoisting2(new Array(5)); |
| 113 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); | 116 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); |
| 114 | 117 |
| 115 // Make sure that non-element related map checks do get hoisted if they use | 118 // Make sure that non-element related map checks do get hoisted if they use |
| 116 // the transitioned map for the check and all transitions that they depend | 119 // the transitioned map for the check and all transitions that they depend |
| 117 // upon can hoisted, too. | 120 // upon can hoisted, too. |
| 118 function testExactMapHoisting3(a) { | 121 function testExactMapHoisting3(a) { |
| 119 var object = new Object(); | 122 var object = new Object(); |
| 120 a.foo = 0; | 123 a.foo = 0; |
| 121 a[0] = 0; | 124 a[0] = 0; |
| 122 a[1] = 1; | 125 a[1] = 1; |
| 123 var count = 3; | 126 var count = 3; |
| 124 do { | 127 do { |
| 125 a[1] = 2.5; | 128 a[1] = 2.5; |
| 126 a.foo = object; // This map check should be hoistable because all elements | 129 a.foo = object; // This map check should be hoistable because all elements |
| 127 // transitions in the loop can also be hoisted. | 130 // transitions in the loop can also be hoisted. |
| 128 } while (--count > 0); | 131 } while (--count > 0); |
| 129 } | 132 } |
| 130 | 133 |
| 131 var add_transition = new Array(5); | 134 var add_transition = new Array(5); |
| 132 add_transition.foo = 0; | 135 add_transition.foo = 0; |
| 133 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created | 136 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created |
| 134 testExactMapHoisting3(new Array(5)); | 137 testExactMapHoisting3(new Array(5)); |
| 138 testExactMapHoisting3(new Array(5)); |
| 135 %OptimizeFunctionOnNextCall(testExactMapHoisting3); | 139 %OptimizeFunctionOnNextCall(testExactMapHoisting3); |
| 136 testExactMapHoisting3(new Array(5)); | 140 testExactMapHoisting3(new Array(5)); |
| 137 testExactMapHoisting3(new Array(5)); | 141 testExactMapHoisting3(new Array(5)); |
| 138 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); | 142 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); |
| 139 | 143 |
| 140 function testDominatingTransitionHoisting1(a) { | 144 function testDominatingTransitionHoisting1(a) { |
| 141 var object = new Object(); | 145 var object = new Object(); |
| 142 a[0] = 0; | 146 a[0] = 0; |
| 143 var count = 3; | 147 var count = 3; |
| 144 do { | 148 do { |
| 145 if (a.baz != true) { | 149 if (a.baz != true) { |
| 146 a[1] = 2.5; | 150 a[1] = 2.5; |
| 147 } | 151 } |
| 148 a[0] = object; | 152 a[0] = object; |
| 149 } while (--count > 3); | 153 } while (--count > 3); |
| 150 } | 154 } |
| 151 | 155 |
| 152 testDominatingTransitionHoisting1(new Array(5)); | 156 testDominatingTransitionHoisting1(new Array(5)); |
| 157 testDominatingTransitionHoisting1(new Array(5)); |
| 153 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); | 158 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); |
| 154 testDominatingTransitionHoisting1(new Array(5)); | 159 testDominatingTransitionHoisting1(new Array(5)); |
| 155 testDominatingTransitionHoisting1(new Array(5)); | 160 testDominatingTransitionHoisting1(new Array(5)); |
| 156 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); | 161 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); |
| 157 | 162 |
| 158 function testHoistingWithSideEffect(a) { | 163 function testHoistingWithSideEffect(a) { |
| 159 var object = new Object(); | 164 var object = new Object(); |
| 160 a[0] = 0; | 165 a[0] = 0; |
| 161 var count = 3; | 166 var count = 3; |
| 162 do { | 167 do { |
| 163 assertTrue(true); | 168 assertTrue(true); |
| 164 a[0] = object; | 169 a[0] = object; |
| 165 } while (--count > 3); | 170 } while (--count > 3); |
| 166 } | 171 } |
| 167 | 172 |
| 168 testHoistingWithSideEffect(new Array(5)); | 173 testHoistingWithSideEffect(new Array(5)); |
| 174 testHoistingWithSideEffect(new Array(5)); |
| 169 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); | 175 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); |
| 170 testHoistingWithSideEffect(new Array(5)); | 176 testHoistingWithSideEffect(new Array(5)); |
| 171 testHoistingWithSideEffect(new Array(5)); | 177 testHoistingWithSideEffect(new Array(5)); |
| 172 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); | 178 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); |
| 173 | 179 |
| 174 function testStraightLineDupeElinination(a,b,c,d,e,f) { | 180 function testStraightLineDupeElinination(a,b,c,d,e,f) { |
| 175 var count = 3; | 181 var count = 3; |
| 176 do { | 182 do { |
| 177 assertTrue(true); | 183 assertTrue(true); |
| 178 a[0] = b; | 184 a[0] = b; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 202 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); | 208 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); |
| 203 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); | 209 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); |
| 204 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); | 210 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); |
| 205 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); | 211 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); |
| 206 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); | 212 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); |
| 207 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); | 213 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); |
| 208 testStraightLineDupeElinination(new Array(5)); | 214 testStraightLineDupeElinination(new Array(5)); |
| 209 testStraightLineDupeElinination(new Array(5)); | 215 testStraightLineDupeElinination(new Array(5)); |
| 210 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination)); | 216 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination)); |
| 211 } | 217 } |
| OLD | NEW |