I understand that js' JIT compiler will deoptimize the warm or hot code in case datatype changes in a loop (like one element in array is string whereas rest were int).
But i have few scenarios where i'm not able to understand will the code be deoptimized or not
- Same loop is used for two arrays where one array contains strings and other ints. Will compiler deoptimize the code here or create two copies? (I understand it should be two copies).
- In case of array of object. Considering all scenarios like
- Manipulated sub-property is of different type.
- Same sub-properties for each object but one object has one property missing.
- Missing property is not manipulated inside the loop.
- Missing property is manipulated inside loop (null case is handled).
- All objects have different properties (New property is added, or manipulation is done using property location).