| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 297 |
| 299 function instanceof_check(type) { | 298 function instanceof_check(type) { |
| 300 assertTrue(new type() instanceof type); | 299 assertTrue(new type() instanceof type); |
| 301 assertTrue(new type(5) instanceof type); | 300 assertTrue(new type(5) instanceof type); |
| 302 assertTrue(new type(1,2,3) instanceof type); | 301 assertTrue(new type(1,2,3) instanceof type); |
| 303 } | 302 } |
| 304 | 303 |
| 305 var realmBArray = Realm.eval(realmB, "Array"); | 304 var realmBArray = Realm.eval(realmB, "Array"); |
| 306 instanceof_check(Array); | 305 instanceof_check(Array); |
| 307 instanceof_check(realmBArray); | 306 instanceof_check(realmBArray); |
| 308 %OptimizeFunctionOnNextCall(instanceof_check); | 307 %OptimizeFunctionOnNextCall(instanceof_check); |
| 308 |
| 309 // No de-opt will occur because HCallNewArray wasn't selected, on account of |
| 310 // the call site not being monomorphic to Array. |
| 309 instanceof_check(Array); | 311 instanceof_check(Array); |
| 310 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 312 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 311 instanceof_check(realmBArray); | 313 instanceof_check(realmBArray); |
| 314 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 315 |
| 316 // Try to optimize again, but first clear all type feedback, and allow it |
| 317 // to be monomorphic on first call. Only after crankshafting do we introduce |
| 318 // realmBArray. This should deopt the method. |
| 319 %DeoptimizeFunction(instanceof_check); |
| 320 %ClearFunctionTypeFeedback(instanceof_check); |
| 321 instanceof_check(Array); |
| 322 instanceof_check(Array); |
| 323 %OptimizeFunctionOnNextCall(instanceof_check); |
| 324 instanceof_check(Array); |
| 325 assertTrue(2 != %GetOptimizationStatus(instanceof_check)); |
| 326 |
| 327 instanceof_check(realmBArray); |
| 312 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); | 328 assertTrue(1 != %GetOptimizationStatus(instanceof_check)); |
| 313 } | 329 } |
| OLD | NEW |