Changeset 268783 in webkit
- Timestamp:
- Oct 20, 2020, 9:00:05 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/ftl-osr-entry-should-not-exit-to-bc-zero.js (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/ftl/FTLForOSREntryJITCode.h (modified) (1 diff)
-
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (modified) (1 diff)
-
Source/JavaScriptCore/ftl/FTLOSREntry.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r268773 r268783 1 2020-10-20 Saam Barati <sbarati@apple.com> 2 3 Don't OSR exit to bc#0 for FTL argument type checks during loop OSR entry 4 https://bugs.webkit.org/show_bug.cgi?id=217925 5 <rdar://problem/70369407> 6 7 Reviewed by Michael Saboff and Tadeu Zagallo. 8 9 * stress/ftl-osr-entry-should-not-exit-to-bc-zero.js: Added. 10 1 11 2020-10-20 Michael Saboff <msaboff@apple.com> 2 12 -
trunk/Source/JavaScriptCore/ChangeLog
r268773 r268783 1 2020-10-20 Saam Barati <sbarati@apple.com> 2 3 Don't OSR exit to bc#0 for FTL argument type checks during loop OSR entry 4 https://bugs.webkit.org/show_bug.cgi?id=217925 5 <rdar://problem/70369407> 6 7 Reviewed by Michael Saboff and Tadeu Zagallo. 8 9 When the FTL was emitting type checks for the named arguments of a function, 10 it was always emitting these type checks with an exit origin of bc#0. It was 11 doing this even if we were an OSR entry compilation! This meant that type 12 checks for arguments that failed during loop OSR entry would incorrectly exit 13 back to bc#0. 14 15 This patch fixes this by having the OSR entry runtime code validate the 16 argument types before OSR entering. The current OSR entry compiled code in 17 the FTL is designed to only allow exiting after all ExtractOSREntryLocal and 18 MovHints have executed, so it is simpler to put the type checks in the runtime 19 instead of the compiled code. 20 21 This patch also makes it so we do exponential backoff when failing to OSR 22 enter. This is needed due to insufficient profiling where we never properly 23 profile the type of arguments. Before this, we'd OSR exit in the FTL code 24 itself, which does exponential backoff when recompiling. This patch builds 25 this same exponential backoff in for when we fail to OSR enter enough times 26 to give up on the OSR entry compilation. 27 28 * ftl/FTLForOSREntryJITCode.h: 29 * ftl/FTLLowerDFGToB3.cpp: 30 (JSC::FTL::DFG::LowerDFGToB3::lower): 31 * ftl/FTLOSREntry.cpp: 32 (JSC::FTL::prepareOSREntry): 33 1 34 2020-10-20 Michael Saboff <msaboff@apple.com> 2 35 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r268385 r268783 3769 3769 } 3770 3770 3771 auto failedOSREntry = [&] (CodeBlock* entryBlock) { 3772 FTL::ForOSREntryJITCode* entryCode = entryBlock->jitCode()->ftlForOSREntry(); 3773 entryCode->countEntryFailure(); 3774 if (entryCode->entryFailureCount() < 3775 Options::ftlOSREntryFailureCountForReoptimization()) { 3776 CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("OSR entry failed")); 3777 jitCode->setOptimizationThresholdBasedOnCompilationResult( 3778 codeBlock, CompilationDeferred); 3779 return nullptr; 3780 } 3781 3782 CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("OSR entry failed too many times")); 3783 codeBlock->baselineVersion()->countReoptimization(); 3784 jitCode->clearOSREntryBlockAndResetThresholds(codeBlock); 3785 return nullptr; 3786 }; 3787 3771 3788 // If we can OSR Enter, do it right away. 3772 3789 if (canOSREnterHere) { … … 3782 3799 return tagCodePtrWithStackPointerForJITCall(untagCodePtr<char*, JSEntryPtrTag>(address), callFrame); 3783 3800 } 3801 3802 return failedOSREntry(entryBlock); 3784 3803 } 3785 3804 } … … 3823 3842 } 3824 3843 3825 FTL::ForOSREntryJITCode* entryCode = entryBlock->jitCode()->ftlForOSREntry(); 3826 entryCode->countEntryFailure(); 3827 if (entryCode->entryFailureCount() < 3828 Options::ftlOSREntryFailureCountForReoptimization()) { 3829 CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("OSR entry failed")); 3830 jitCode->setOptimizationThresholdBasedOnCompilationResult( 3831 codeBlock, CompilationDeferred); 3832 return nullptr; 3833 } 3834 3835 // OSR entry failed. Oh no! This implies that we need to retry. We retry 3836 // without exponential backoff and we only do this for the entry code block. 3837 CODEBLOCK_LOG_EVENT(codeBlock, "delayFTLCompile", ("OSR entry failed too many times")); 3838 jitCode->clearOSREntryBlockAndResetThresholds(codeBlock); 3839 return nullptr; 3844 return failedOSREntry(entryBlock); 3840 3845 } 3841 3846 … … 3934 3939 void* address = FTL::prepareOSREntry(vm, callFrame, codeBlock, jitCode->osrEntryBlock(), originBytecodeIndex, streamIndex); 3935 3940 if (!address) 3936 return nullptr;3941 return failedOSREntry(jitCode->osrEntryBlock()); 3937 3942 return tagCodePtrWithStackPointerForJITCall(untagCodePtr<char*, JSEntryPtrTag>(address), callFrame); 3938 3943 } -
trunk/Source/JavaScriptCore/ftl/FTLForOSREntryJITCode.h
r261567 r268783 56 56 57 57 ForOSREntryJITCode* ftlForOSREntry() final; 58 58 Vector<DFG::FlushFormat>& argumentFlushFormats() { return m_argumentFlushFormats; } 59 59 60 private: 61 Vector<DFG::FlushFormat> m_argumentFlushFormats; 60 62 ScratchBuffer* m_entryBuffer; // Only for OSR entry code blocks. 61 63 BytecodeIndex m_bytecodeIndex; -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r268656 r268783 359 359 } 360 360 361 for (unsigned i = codeBlock()->numParameters(); i--;) { 362 MethodOfGettingAValueProfile profile(&m_graph.m_profiledBlock->valueProfileForArgument(i)); 363 VirtualRegister operand = virtualRegisterForArgumentIncludingThis(i); 364 LValue jsValue = m_out.load64(addressFor(operand)); 365 366 switch (m_graph.m_argumentFormats[0][i]) { 367 case FlushedInt32: 368 speculate(BadType, jsValueValue(jsValue), profile, isNotInt32(jsValue)); 369 break; 370 case FlushedBoolean: 371 speculate(BadType, jsValueValue(jsValue), profile, isNotBoolean(jsValue)); 372 break; 373 case FlushedCell: 374 speculate(BadType, jsValueValue(jsValue), profile, isNotCell(jsValue)); 375 break; 376 case FlushedJSValue: 377 break; 378 default: 379 DFG_CRASH(m_graph, nullptr, "Bad flush format for argument"); 380 break; 361 if (m_graph.m_plan.mode() == FTLForOSREntryMode) { 362 auto* jitCode = m_ftlState.jitCode->ftlForOSREntry(); 363 jitCode->argumentFlushFormats().reserveInitialCapacity(codeBlock()->numParameters()); 364 for (unsigned i = codeBlock()->numParameters(); i--;) 365 jitCode->argumentFlushFormats().append(m_graph.m_argumentFormats[0][i]); 366 } else { 367 for (unsigned i = codeBlock()->numParameters(); i--;) { 368 MethodOfGettingAValueProfile profile(&m_graph.m_profiledBlock->valueProfileForArgument(i)); 369 VirtualRegister operand = virtualRegisterForArgumentIncludingThis(i); 370 LValue jsValue = m_out.load64(addressFor(operand)); 371 372 switch (m_graph.m_argumentFormats[0][i]) { 373 case FlushedInt32: 374 speculate(BadType, jsValueValue(jsValue), profile, isNotInt32(jsValue)); 375 break; 376 case FlushedBoolean: 377 speculate(BadType, jsValueValue(jsValue), profile, isNotBoolean(jsValue)); 378 break; 379 case FlushedCell: 380 speculate(BadType, jsValueValue(jsValue), profile, isNotCell(jsValue)); 381 break; 382 case FlushedJSValue: 383 break; 384 default: 385 DFG_CRASH(m_graph, nullptr, "Bad flush format for argument"); 386 break; 387 } 381 388 } 382 389 } 390 383 391 m_out.jump(firstDFGBasicBlock); 384 392 } -
trunk/Source/JavaScriptCore/ftl/FTLOSREntry.cpp
r264804 r268783 75 75 JSValue valueOnStack = callFrame->r(virtualRegisterForArgumentIncludingThis(argument)).asanUnsafeJSValue(); 76 76 Optional<JSValue> reconstructedValue = values.argument(argument); 77 { 78 JSValue valueToValidate = reconstructedValue ? *reconstructedValue : valueOnStack; 79 auto flushFormat = entryCode->argumentFlushFormats()[argument]; 80 switch (flushFormat) { 81 case DFG::FlushedInt32: 82 if (!valueToValidate.isInt32()) 83 return nullptr; 84 break; 85 case DFG::FlushedBoolean: 86 if (!valueToValidate.isBoolean()) 87 return nullptr; 88 break; 89 case DFG::FlushedCell: 90 if (!valueToValidate.isCell()) 91 return nullptr; 92 break; 93 case DFG::FlushedJSValue: 94 break; 95 default: 96 dataLogLn("Unknown flush format for argument during FTL osr entry: ", flushFormat); 97 RELEASE_ASSERT_NOT_REACHED(); 98 break; 99 } 100 } 101 77 102 if (!argument) { 78 103 // |this| argument can be unboxed. We should store boxed value instead for loop OSR entry since FTL assumes that all arguments are flushed JSValue.
Note:
See TracChangeset
for help on using the changeset viewer.