|
| 1 | +2021-05-22 Ross Kirsling <ross.kirsling@sony.com> |
| 2 | + |
| 3 | + Support Ergonomic Brand Checks proposal (`#x in obj`) |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=221093 |
| 5 | + |
| 6 | + Reviewed by Caio Araujo Neponoceno de Lima. |
| 7 | + |
| 8 | + This patch implements the following Stage 3 proposal (behind a runtime option): |
| 9 | + https://github.com/tc39/proposal-private-fields-in-in |
| 10 | + |
| 11 | + Specifically, it extends the `in` keyword to allow the LHS to be a private name, |
| 12 | + thereby allowing users to implement Array.isArray-esque brand checks for their own classes |
| 13 | + *without* having to wrap a private member get in a try-catch. |
| 14 | + |
| 15 | + For example: |
| 16 | + ``` |
| 17 | + class C { |
| 18 | + #x; |
| 19 | + static isC(obj) { return #x in obj; } |
| 20 | + } |
| 21 | + ``` |
| 22 | + |
| 23 | + This is done by adding two new bytecode ops, HasPrivateName and HasPrivateBrand. For the moment, |
| 24 | + these are implemented without fast paths, as we should do so for InByVal first and then have these follow suit. |
| 25 | + |
| 26 | + * bytecode/BytecodeList.rb: |
| 27 | + * bytecode/BytecodeUseDef.cpp: |
| 28 | + (JSC::computeUsesForBytecodeIndexImpl): |
| 29 | + (JSC::computeDefsForBytecodeIndexImpl): |
| 30 | + * bytecompiler/BytecodeGenerator.cpp: |
| 31 | + (JSC::BytecodeGenerator::emitHasPrivateName): |
| 32 | + (JSC::BytecodeGenerator::emitHasPrivateBrand): |
| 33 | + (JSC::BytecodeGenerator::emitCheckPrivateBrand): |
| 34 | + * bytecompiler/BytecodeGenerator.h: |
| 35 | + * bytecompiler/NodesCodegen.cpp: |
| 36 | + (JSC::InNode::emitBytecode): |
| 37 | + * dfg/DFGAbstractInterpreterInlines.h: |
| 38 | + (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): |
| 39 | + * dfg/DFGByteCodeParser.cpp: |
| 40 | + (JSC::DFG::ByteCodeParser::parseBlock): |
| 41 | + * dfg/DFGCapabilities.cpp: |
| 42 | + (JSC::DFG::capabilityLevel): |
| 43 | + * dfg/DFGClobberize.h: |
| 44 | + (JSC::DFG::clobberize): |
| 45 | + * dfg/DFGDoesGC.cpp: |
| 46 | + (JSC::DFG::doesGC): |
| 47 | + * dfg/DFGFixupPhase.cpp: |
| 48 | + (JSC::DFG::FixupPhase::fixupNode): |
| 49 | + * dfg/DFGNodeType.h: |
| 50 | + * dfg/DFGPredictionPropagationPhase.cpp: |
| 51 | + * dfg/DFGSafeToExecute.h: |
| 52 | + (JSC::DFG::safeToExecute): |
| 53 | + * dfg/DFGSpeculativeJIT.cpp: |
| 54 | + (JSC::DFG::SpeculativeJIT::compileHasPrivateName): |
| 55 | + (JSC::DFG::SpeculativeJIT::compileHasPrivateBrand): |
| 56 | + * dfg/DFGSpeculativeJIT.h: |
| 57 | + * dfg/DFGSpeculativeJIT32_64.cpp: |
| 58 | + (JSC::DFG::SpeculativeJIT::compile): |
| 59 | + * dfg/DFGSpeculativeJIT64.cpp: |
| 60 | + (JSC::DFG::SpeculativeJIT::compile): |
| 61 | + * ftl/FTLCapabilities.cpp: |
| 62 | + (JSC::FTL::canCompile): |
| 63 | + * ftl/FTLLowerDFGToB3.cpp: |
| 64 | + (JSC::FTL::DFG::LowerDFGToB3::compileNode): |
| 65 | + (JSC::FTL::DFG::LowerDFGToB3::compileHasPrivateName): |
| 66 | + (JSC::FTL::DFG::LowerDFGToB3::compileHasPrivateBrand): |
| 67 | + * jit/JIT.cpp: |
| 68 | + (JSC::JIT::privateCompileMainPass): |
| 69 | + * jit/JITOperations.cpp: |
| 70 | + (JSC::JSC_DEFINE_JIT_OPERATION): |
| 71 | + * jit/JITOperations.h: |
| 72 | + * llint/LowLevelInterpreter.asm: |
| 73 | + * parser/ASTBuilder.h: |
| 74 | + (JSC::ASTBuilder::createPrivateIdentifierNode): |
| 75 | + * parser/NodeConstructors.h: |
| 76 | + (JSC::PrivateIdentifierNode::PrivateIdentifierNode): |
| 77 | + * parser/Nodes.h: |
| 78 | + (JSC::ExpressionNode::isPrivateIdentifier const): |
| 79 | + * parser/Parser.cpp: |
| 80 | + (JSC::Parser<LexerType>::parseBinaryExpression): |
| 81 | + * parser/SyntaxChecker.h: |
| 82 | + (JSC::SyntaxChecker::createPrivateIdentifierNode): |
| 83 | + * parser/VariableEnvironment.h: |
| 84 | + * runtime/CommonSlowPaths.cpp: |
| 85 | + (JSC::JSC_DEFINE_COMMON_SLOW_PATH): |
| 86 | + * runtime/CommonSlowPaths.h: |
| 87 | + * runtime/JSObject.h: |
| 88 | + * runtime/JSObjectInlines.h: |
| 89 | + (JSC::JSObject::hasPrivateField): |
| 90 | + (JSC::JSObject::hasPrivateBrand): |
| 91 | + (JSC::JSObject::checkPrivateBrand): |
| 92 | + * runtime/OptionsList.h: |
| 93 | + |
1 | 94 | 2021-05-22 Chris Dumez <cdumez@apple.com> |
2 | 95 |
|
3 | 96 | Replace LockHolder with Locker in local variables |
|
0 commit comments