|
| 1 | +2021-09-26 Yusuke Suzuki <ysuzuki@apple.com> |
| 2 | + |
| 3 | + [JSC] Optimize PutByVal with for-in |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=230801 |
| 5 | + |
| 6 | + Reviewed by Saam Barati. |
| 7 | + |
| 8 | + We found that some of Speedometer2 subtests are heavily using for-in with PutByVal or the other DFG nodes. |
| 9 | + And we also found that we are using polluted non-good type for the property names from for-in: String | Other. |
| 10 | + The reason is that we are returning null when op_enumerator_next finishes instead of string. And this design |
| 11 | + forces DFG and FTL to return null from EnumeratorNextUpdatePropertyName at the end of iteration. This pollutes |
| 12 | + the type of property names as String | Other instead of String, and leading to suboptimal DFG nodes. |
| 13 | + |
| 14 | + In this patch, we add special sentinel string in vm.smallString.sentinelString(). We know that this string cell |
| 15 | + pointer will be never returned from EnumeratorNextUpdatePropertyName in the normal for-in iteration. This is easy |
| 16 | + since we are always allocating a JSString when creating JSPropertyNameEnumerator. So this string cell (not the content) |
| 17 | + is always different from pre-allocated vm.smallString.sentinelString(). So, we use this special string pointer |
| 18 | + as a sentinel instead of null so that we can avoid polluting return type of EnumeratorNextUpdatePropertyName. |
| 19 | + |
| 20 | + To check the sentinel in LLInt / Baseline, this patch adds jeq_ptr, which performs cell pointer comparison and do |
| 21 | + not check string content equality. We do not need to have an implementation in DFG since we already have CompareEqPtr |
| 22 | + for existing jneq_ptr bytecode. |
| 23 | + |
| 24 | + We also clean up DFG operation related to PutByVal. |
| 25 | + |
| 26 | + ---------------------------------------------------------------------------------------------------------------------------------- |
| 27 | + | subtest | ms | ms | b / a | pValue (significance using False Discovery Rate) | |
| 28 | + ---------------------------------------------------------------------------------------------------------------------------------- |
| 29 | + | Elm-TodoMVC |116.010000 |112.701667 |0.971482 | 0.000000 (significant) | |
| 30 | + | VueJS-TodoMVC |22.995000 |23.023333 |1.001232 | 0.907086 | |
| 31 | + | EmberJS-TodoMVC |125.498333 |125.525000 |1.000212 | 0.932546 | |
| 32 | + | BackboneJS-TodoMVC |45.700000 |45.975000 |1.006018 | 0.084799 | |
| 33 | + | Preact-TodoMVC |16.681667 |16.610000 |0.995704 | 0.722758 | |
| 34 | + | AngularJS-TodoMVC |123.753333 |123.740000 |0.999892 | 0.971431 | |
| 35 | + | Vanilla-ES2015-TodoMVC |61.255000 |61.380000 |1.002041 | 0.300654 | |
| 36 | + | Inferno-TodoMVC |58.646667 |58.948333 |1.005144 | 0.267611 | |
| 37 | + | Flight-TodoMVC |73.283333 |72.801667 |0.993427 | 0.207389 | |
| 38 | + | Angular2-TypeScript-TodoMVC |39.746667 |40.015000 |1.006751 | 0.449821 | |
| 39 | + | VanillaJS-TodoMVC |50.096667 |49.823333 |0.994544 | 0.162020 | |
| 40 | + | jQuery-TodoMVC |212.870000 |213.196667 |1.001535 | 0.371944 | |
| 41 | + | EmberJS-Debug-TodoMVC |331.878333 |332.710000 |1.002506 | 0.094499 | |
| 42 | + | React-TodoMVC |83.078333 |82.726667 |0.995767 | 0.076143 | |
| 43 | + | React-Redux-TodoMVC |136.018333 |133.935000 |0.984683 | 0.000000 (significant) | |
| 44 | + | Vanilla-ES2015-Babel-Webpack-TodoMVC |59.743333 |59.643333 |0.998326 | 0.393671 | |
| 45 | + ---------------------------------------------------------------------------------------------------------------------------------- |
| 46 | + a mean = 271.75873 |
| 47 | + b mean = 272.45804 |
| 48 | + pValue = 0.0263030803 |
| 49 | + (Bigger means are better.) |
| 50 | + 1.003 times better |
| 51 | + Results ARE significant |
| 52 | + |
| 53 | + * builtins/BuiltinNames.h: |
| 54 | + * bytecode/BytecodeList.rb: |
| 55 | + * bytecode/BytecodeUseDef.cpp: |
| 56 | + (JSC::computeUsesForBytecodeIndexImpl): |
| 57 | + (JSC::computeDefsForBytecodeIndexImpl): |
| 58 | + * bytecode/LinkTimeConstant.h: |
| 59 | + * bytecode/Opcode.h: |
| 60 | + (JSC::isBranch): |
| 61 | + * bytecode/PreciseJumpTargetsInlines.h: |
| 62 | + * bytecompiler/BytecodeGenerator.cpp: |
| 63 | + (JSC::GenericLabel<JSGeneratorTraits>::setLocation): |
| 64 | + (JSC::BytecodeGenerator::emitJumpIfSentinelString): |
| 65 | + * bytecompiler/BytecodeGenerator.h: |
| 66 | + * bytecompiler/NodesCodegen.cpp: |
| 67 | + (JSC::ForInNode::emitBytecode): |
| 68 | + * dfg/DFGAbstractInterpreterInlines.h: |
| 69 | + (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): |
| 70 | + * dfg/DFGByteCodeParser.cpp: |
| 71 | + (JSC::DFG::ByteCodeParser::parseBlock): |
| 72 | + * dfg/DFGCapabilities.cpp: |
| 73 | + (JSC::DFG::capabilityLevel): |
| 74 | + * dfg/DFGOperations.cpp: |
| 75 | + (JSC::DFG::putByVal): |
| 76 | + (JSC::DFG::putByValInternal): |
| 77 | + (JSC::DFG::putByValCellInternal): |
| 78 | + (JSC::DFG::JSC_DEFINE_JIT_OPERATION): |
| 79 | + * dfg/DFGOperations.h: |
| 80 | + * dfg/DFGPredictionPropagationPhase.cpp: |
| 81 | + * dfg/DFGSpeculativeJIT.cpp: |
| 82 | + (JSC::DFG::SpeculativeJIT::compileEnumeratorNextUpdatePropertyName): |
| 83 | + * ftl/FTLLowerDFGToB3.cpp: |
| 84 | + (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): |
| 85 | + * jit/JIT.cpp: |
| 86 | + (JSC::JIT::privateCompileMainPass): |
| 87 | + * jit/JIT.h: |
| 88 | + * jit/JITOpcodes.cpp: |
| 89 | + (JSC::JIT::emit_op_jeq_ptr): |
| 90 | + * jit/JITOpcodes32_64.cpp: |
| 91 | + (JSC::JIT::emit_op_jeq_ptr): |
| 92 | + * jit/JITPropertyAccess.cpp: |
| 93 | + (JSC::JIT::emit_op_enumerator_next): |
| 94 | + * llint/LowLevelInterpreter32_64.asm: |
| 95 | + * llint/LowLevelInterpreter64.asm: |
| 96 | + * runtime/CommonSlowPaths.cpp: |
| 97 | + (JSC::JSC_DEFINE_COMMON_SLOW_PATH): |
| 98 | + * runtime/JSGlobalObject.cpp: |
| 99 | + (JSC::JSGlobalObject::init): |
| 100 | + * runtime/SmallStrings.cpp: |
| 101 | + (JSC::SmallStrings::initializeCommonStrings): |
| 102 | + (JSC::SmallStrings::visitStrongReferences): |
| 103 | + * runtime/SmallStrings.h: |
| 104 | + (JSC::SmallStrings::sentinelString const): |
| 105 | + |
1 | 106 | 2021-09-26 Commit Queue <commit-queue@webkit.org> |
2 | 107 |
|
3 | 108 | Unreviewed, reverting r283083 and r283088. |
|
0 commit comments