| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 290   var realmB = Realm.create(); | 290   var realmB = Realm.create(); | 
| 291   assertEquals(0, realmA); | 291   assertEquals(0, realmA); | 
| 292   assertEquals(1, realmB); | 292   assertEquals(1, realmB); | 
| 293 | 293 | 
| 294   function instanceof_check(type) { | 294   function instanceof_check(type) { | 
| 295     assertTrue(new type() instanceof type); | 295     assertTrue(new type() instanceof type); | 
| 296     assertTrue(new type(5) instanceof type); | 296     assertTrue(new type(5) instanceof type); | 
| 297     assertTrue(new type(1,2,3) instanceof type); | 297     assertTrue(new type(1,2,3) instanceof type); | 
| 298   } | 298   } | 
| 299 | 299 | 
|  | 300   function instanceof_check2(type) { | 
|  | 301     assertTrue(new type() instanceof type); | 
|  | 302     assertTrue(new type(5) instanceof type); | 
|  | 303     assertTrue(new type(1,2,3) instanceof type); | 
|  | 304   } | 
|  | 305 | 
| 300   var realmBArray = Realm.eval(realmB, "Array"); | 306   var realmBArray = Realm.eval(realmB, "Array"); | 
| 301   instanceof_check(Array); | 307   instanceof_check(Array); | 
| 302   instanceof_check(realmBArray); | 308   instanceof_check(realmBArray); | 
|  | 309 | 
|  | 310   // instanceof_check2 is here because the call site goes through a state. | 
|  | 311   // Since instanceof_check(Array) was first called with the current context | 
|  | 312   // Array function, it went from (uninit->Array) then (Array->megamorphic). | 
|  | 313   // We'll get a different state traversal if we start with realmBArray. | 
|  | 314   // It'll go (uninit->realmBArray) then (realmBArray->megamorphic). Recognize | 
|  | 315   // that state "Array" implies an AllocationSite is present, and code is | 
|  | 316   // configured to use it. | 
|  | 317   instanceof_check2(realmBArray); | 
|  | 318   instanceof_check2(Array); | 
|  | 319 | 
| 303   %OptimizeFunctionOnNextCall(instanceof_check); | 320   %OptimizeFunctionOnNextCall(instanceof_check); | 
| 304 | 321 | 
| 305   // No de-opt will occur because HCallNewArray wasn't selected, on account of | 322   // No de-opt will occur because HCallNewArray wasn't selected, on account of | 
| 306   // the call site not being monomorphic to Array. | 323   // the call site not being monomorphic to Array. | 
| 307   instanceof_check(Array); | 324   instanceof_check(Array); | 
| 308   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 325   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 
| 309   instanceof_check(realmBArray); | 326   instanceof_check(realmBArray); | 
| 310   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 327   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 
| 311 | 328 | 
| 312   // Try to optimize again, but first clear all type feedback, and allow it | 329   // 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 | 330   // to be monomorphic on first call. Only after crankshafting do we introduce | 
| 314   // realmBArray. This should deopt the method. | 331   // realmBArray. This should deopt the method. | 
| 315   %DeoptimizeFunction(instanceof_check); | 332   %DeoptimizeFunction(instanceof_check); | 
| 316   %ClearFunctionTypeFeedback(instanceof_check); | 333   %ClearFunctionTypeFeedback(instanceof_check); | 
| 317   instanceof_check(Array); | 334   instanceof_check(Array); | 
| 318   instanceof_check(Array); | 335   instanceof_check(Array); | 
| 319   %OptimizeFunctionOnNextCall(instanceof_check); | 336   %OptimizeFunctionOnNextCall(instanceof_check); | 
| 320   instanceof_check(Array); | 337   instanceof_check(Array); | 
| 321   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 338   assertTrue(2 != %GetOptimizationStatus(instanceof_check)); | 
| 322 | 339 | 
| 323   instanceof_check(realmBArray); | 340   instanceof_check(realmBArray); | 
| 324   assertTrue(1 != %GetOptimizationStatus(instanceof_check)); | 341   assertTrue(1 != %GetOptimizationStatus(instanceof_check)); | 
| 325 } | 342 } | 
| OLD | NEW | 
|---|