• danno's avatar
    [turbofan]: Add a context relaxation Reducer · cca5e74a
    danno authored
    In many cases, the context that TurboFan's ASTGraphBuilder or subsequent
    reduction operations attaches to nodes does not need to be that exact
    context, but rather only needs to be one with the same native context,
    because it is used internally only to fetch the native context, e.g. for
    creating and throwing exceptions.
    
    This reducer recognizes common cases where the context that is specified
    for a node can be relaxed to a canonical, less specific one. This
    relaxed context can either be the enclosing function's context or a specific
    Module or Script context that is explicitly created within the function.
    
    This optimization is especially important for TurboFan-generated code stubs
    which use context specialization and inlining to generate optimal code.
    Without context relaxation, many extraneous moves are generated to pass
    exactly the right context to internal functions like ToNumber and
    AllocateHeapNumber, which only need the native context. By turning context
    relaxation on, these moves disappear because all these common internal
    context uses are unified to the context passed into the stub function, which
    is typically already in the correct context register and remains there for
    short stubs. It also eliminates the explicit use of a specialized context
    constant in the code stub in these cases, which could cause memory leaks.
    
    Review URL: https://codereview.chromium.org/1244583003
    
    Cr-Commit-Position: refs/heads/master@{#29763}
    cca5e74a
js-context-relaxation.h 1.07 KB