Currently function context specialization is fairly limited, it can only kick in if the function that we optimize has only exactly one closure, and then we specialize to that closures' context. We could generalize it a bit to allow specialization to outer contexts, such that we can benefit from it, even for local closures, i.e. arrow functions that are passed as callbacks. Currently these local functions suffer from a lot of hole checks if they refer to const declarations outside.
For this we'd need to have a way to record the specialization depth on the code object and share the code object if the specialization depth is compatible (within the native context).
This was found to be an issue with crbug.com/v8/6971 for example, where the right-hand side of the instanceof wasn't a constant known to TurboFan. This was fixed in a more general way for instanceof, but that still leaves us with code that has to perform all kinds of checks that it wouldn't need to with generalized function context specialization.