Ignore:
Timestamp:
Jul 23, 2020, 4:08:19 PM (5 years ago)
Author:
[email protected]
Message:

[JSC] FTL OSR entry should store boxed |this|
https://bugs.webkit.org/show_bug.cgi?id=214675
<rdar://problem/65474072>

Reviewed by Michael Saboff and Mark Lam.

In this patch, after ensuring that we will go to FTL OSR entry, we store boxed |this| instead of the unboxed value
to agree to the FTL assumption that all arguments should be boxed.

  • dfg/DFGOperations.cpp:
  • ftl/FTLOSREntry.cpp:

(JSC::FTL::prepareOSREntry):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLOSREntry.cpp

    r262098 r264804  
    7171    dataLogLnIf(Options::verboseOSR(), "    Values at entry: ", values);
    7272   
     73    Optional<JSValue> reconstructedThis;
    7374    for (int argument = values.numberOfArguments(); argument--;) {
    7475        JSValue valueOnStack = callFrame->r(virtualRegisterForArgumentIncludingThis(argument)).asanUnsafeJSValue();
    7576        Optional<JSValue> reconstructedValue = values.argument(argument);
    76         if ((reconstructedValue && valueOnStack == reconstructedValue.value()) || !argument)
     77        if (!argument) {
     78            // |this| argument can be unboxed. We should store boxed value instead for loop OSR entry since FTL assumes that all arguments are flushed JSValue.
     79            // To make this valid, we will modify the stack on the fly: replacing the value with boxed value.
     80            reconstructedThis = reconstructedValue;
     81            continue;
     82        }
     83        if (reconstructedValue && valueOnStack == reconstructedValue.value())
    7784            continue;
    7885        dataLog("Mismatch between reconstructed values and the value on the stack for argument arg", argument, " for ", *entryCodeBlock, " at ", bytecodeIndex, ":\n");
     
    106113    void* result = entryCode->addressForCall(ArityCheckNotRequired).executableAddress();
    107114    dataLogLnIf(Options::verboseOSR(), "    Entry will succeed, going to address ", RawPointer(result));
     115
     116    // At this point, we're committed to triggering an OSR entry immediately after we return. Hence, it is safe to modify stack here.
     117    if (result) {
     118        if (reconstructedThis)
     119            callFrame->r(virtualRegisterForArgumentIncludingThis(0)) = JSValue::encode(reconstructedThis.value());
     120    }
    108121   
    109122    return result;
Note: See TracChangeset for help on using the changeset viewer.