• Benedikt Meurer's avatar
    [builtins] Refactor the promise resolution and rejection logic. · c0412961
    Benedikt Meurer authored
    This introduces dedicated builtins
    
      - FulfillPromise,
      - RejectPromise, and
      - ResolvePromise,
    
    which perform the corresponding operations from the language
    specification, and removes the redundant entry points and the
    excessive inlining of these operations into other builtins. We
    also add the same logic on the C++ side, so that we don't need
    to go into JavaScript land when resolving/rejecting from the
    API.
    
    The C++ side has a complete implementation, including full support
    for the debugger and the current PromiseHook machinery. This is to
    avoid constantly crossing the boundary for those cases, and to also
    simplify the CSA side (and soon the TurboFan side), where we only
    do the fast-path and bail out to the runtime for the general handling.
    
    On top of this we introduce %_RejectPromise and %_ResolvePromise,
    which are entry points used by the bytecode and parser desugarings
    for async functions, and also used by the V8 Extras API. Thanks to
    this we can uniformly optimize these in TurboFan, where we have
    corresponding operators JSRejectPromise and JSResolvePromise, which
    currently just call into the builtins, but middle-term can be further
    optimized, i.e. to skip the "then" lookup for JSResolvePromise when
    we know something about the resolution.
    
    In TurboFan we can also already inline the default PromiseCapability
    [[Reject]] and [[Resolve]] functions, although this is not as effective
    as it can be right now, until we have inlining support for the Promise
    constructor (being worked on by petermarshall@ right now) and/or SFI
    based CALL_IC feedback.
    
    Overall this change is meant as a refactoring without significant
    performance impact anywhere; it seems to improve performance of
    simple async functions a bit, but otherwise is neutral.
    
    Bug: v8:7253
    Change-Id: Id0b979f9b2843560e38cd8df4b02627dad4b6d8c
    Reviewed-on: https://chromium-review.googlesource.com/911632Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
    Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
    Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
    Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#51260}
    c0412961
builtins-definitions.h 98.7 KB