| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 function assertHoley(obj, name_opt) { | 83 function assertHoley(obj, name_opt) { |
| 84 assertEquals(true, isHoley(obj), name_opt); | 84 assertEquals(true, isHoley(obj), name_opt); |
| 85 } | 85 } |
| 86 | 86 |
| 87 function assertNotHoley(obj, name_opt) { | 87 function assertNotHoley(obj, name_opt) { |
| 88 assertEquals(false, isHoley(obj), name_opt); | 88 assertEquals(false, isHoley(obj), name_opt); |
| 89 } | 89 } |
| 90 | 90 |
| 91 if (support_smi_only_arrays) { | 91 if (support_smi_only_arrays) { |
| 92 | |
| 93 obj = []; | 92 obj = []; |
| 94 assertNotHoley(obj); | 93 assertNotHoley(obj); |
| 95 assertKind(elements_kind.fast_smi_only, obj); | 94 assertKind(elements_kind.fast_smi_only, obj); |
| 96 | 95 |
| 97 obj = [1, 2, 3]; | 96 obj = [1, 2, 3]; |
| 98 assertNotHoley(obj); | 97 assertNotHoley(obj); |
| 99 assertKind(elements_kind.fast_smi_only, obj); | 98 assertKind(elements_kind.fast_smi_only, obj); |
| 100 | 99 |
| 101 obj = new Array(); | 100 obj = new Array(); |
| 102 assertNotHoley(obj); | 101 assertNotHoley(obj); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 127 var literal = [1, 2, 3]; | 126 var literal = [1, 2, 3]; |
| 128 return literal; | 127 return literal; |
| 129 } | 128 } |
| 130 | 129 |
| 131 // Case: [1,2,3] as allocation site | 130 // Case: [1,2,3] as allocation site |
| 132 obj = fastliteralcase(get_standard_literal(), 1); | 131 obj = fastliteralcase(get_standard_literal(), 1); |
| 133 assertKind(elements_kind.fast_smi_only, obj); | 132 assertKind(elements_kind.fast_smi_only, obj); |
| 134 obj = fastliteralcase(get_standard_literal(), 1.5); | 133 obj = fastliteralcase(get_standard_literal(), 1.5); |
| 135 assertKind(elements_kind.fast_double, obj); | 134 assertKind(elements_kind.fast_double, obj); |
| 136 obj = fastliteralcase(get_standard_literal(), 2); | 135 obj = fastliteralcase(get_standard_literal(), 2); |
| 137 // TODO(hpayer): bring the following assert back as soon as allocation | 136 assertKind(elements_kind.fast_double, obj); |
| 138 // sites work again for fast literals | |
| 139 //assertKind(elements_kind.fast_double, obj); | |
| 140 | 137 |
| 141 // The test below is in a loop because arrays that live | 138 // The test below is in a loop because arrays that live |
| 142 // at global scope without the chance of being recreated | 139 // at global scope without the chance of being recreated |
| 143 // don't have allocation site information attached. | 140 // don't have allocation site information attached. |
| 144 for (i = 0; i < 2; i++) { | 141 for (i = 0; i < 2; i++) { |
| 145 obj = fastliteralcase([5, 3, 2], 1.5); | 142 obj = fastliteralcase([5, 3, 2], 1.5); |
| 146 assertKind(elements_kind.fast_double, obj); | 143 assertKind(elements_kind.fast_double, obj); |
| 147 obj = fastliteralcase([3, 6, 2], 1.5); | 144 obj = fastliteralcase([3, 6, 2], 1.5); |
| 148 assertKind(elements_kind.fast_double, obj); | 145 assertKind(elements_kind.fast_double, obj); |
| 149 obj = fastliteralcase([2, 6, 3], 2); | 146 obj = fastliteralcase([2, 6, 3], 2); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 169 var literal = [1, 2, 3, 4]; | 166 var literal = [1, 2, 3, 4]; |
| 170 literal[0] = value; | 167 literal[0] = value; |
| 171 return literal; | 168 return literal; |
| 172 } | 169 } |
| 173 | 170 |
| 174 obj = fastliteralcase_smifast(1); | 171 obj = fastliteralcase_smifast(1); |
| 175 assertKind(elements_kind.fast_smi_only, obj); | 172 assertKind(elements_kind.fast_smi_only, obj); |
| 176 obj = fastliteralcase_smifast("carter"); | 173 obj = fastliteralcase_smifast("carter"); |
| 177 assertKind(elements_kind.fast, obj); | 174 assertKind(elements_kind.fast, obj); |
| 178 obj = fastliteralcase_smifast(2); | 175 obj = fastliteralcase_smifast(2); |
| 179 // TODO(hpayer): bring the following assert back as soon as allocation | 176 assertKind(elements_kind.fast, obj); |
| 180 // sites work again for fast literals | |
| 181 //assertKind(elements_kind.fast, obj); | |
| 182 | 177 |
| 183 function newarraycase_smidouble(value) { | 178 function newarraycase_smidouble(value) { |
| 184 var a = new Array(); | 179 var a = new Array(); |
| 185 a[0] = value; | 180 a[0] = value; |
| 186 return a; | 181 return a; |
| 187 } | 182 } |
| 188 | 183 |
| 189 // Case: new Array() as allocation site, smi->double | 184 // Case: new Array() as allocation site, smi->double |
| 190 obj = newarraycase_smidouble(1); | 185 obj = newarraycase_smidouble(1); |
| 191 assertKind(elements_kind.fast_smi_only, obj); | 186 assertKind(elements_kind.fast_smi_only, obj); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 293 |
| 299 function instanceof_check(type) { | 294 function instanceof_check(type) { |
| 300 assertTrue(new type() instanceof type); | 295 assertTrue(new type() instanceof type); |
| 301 assertTrue(new type(5) instanceof type); | 296 assertTrue(new type(5) instanceof type); |
| 302 assertTrue(new type(1,2,3) instanceof type); | 297 assertTrue(new type(1,2,3) instanceof type); |
| 303 } | 298 } |
| 304 | 299 |
| 305 var realmBArray = Realm.eval(realmB, "Array"); | 300 var realmBArray = Realm.eval(realmB, "Array"); |
| 306 instanceof_check(Array); | 301 instanceof_check(Array); |
| 307 instanceof_check(realmBArray); | 302 instanceof_check(realmBArray); |
| 308 %OptimizeFunctionOnNextCall(instanceof_check); | 303 %OptimizeFunctionOnNextCall(instanceof_check); |
| 304 |
| 305 // No de-opt will occur because HCallNewArray wasn't selected, on account of |
| 306 // the call site not being monomorphic to Array. |
| 309 instanceof_check(Array); | 307 instanceof_check(Array); |
| 310 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 308 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 311 instanceof_check(realmBArray); | 309 instanceof_check(realmBArray); |
| 310 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 311 |
| 312 // Try to optimize again, but first clear all type feedback, and allow it |
| 313 // to be monomorphic on first call. Only after crankshafting do we introduce |
| 314 // realmBArray. This should deopt the method. |
| 315 %DeoptimizeFunction(instanceof_check); |
| 316 %ClearFunctionTypeFeedback(instanceof_check); |
| 317 instanceof_check(Array); |
| 318 instanceof_check(Array); |
| 319 %OptimizeFunctionOnNextCall(instanceof_check); |
| 320 instanceof_check(Array); |
| 321 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 322 |
| 323 instanceof_check(realmBArray); |
| 312 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); | 324 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); |
| 313 } | 325 } |
| OLD | NEW |