Changeset 272580 in webkit
- Timestamp:
- Feb 9, 2021 8:30:24 AM (18 months ago)
- Location:
- trunk
- Files:
-
- 34 added
- 102 edited
- 2 copied
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/private-brand-installed-after-super-call-from-arrow-function.js (added)
-
JSTests/stress/private-brand-installed-after-super-call-from-eval.js (added)
-
JSTests/stress/private-method-brand-check.js (added)
-
JSTests/stress/private-method-change-attribute-from-branded-structure.js (added)
-
JSTests/stress/private-method-change-prototype-from-branded-structure.js (added)
-
JSTests/stress/private-method-check-private-brand-ic.js (added)
-
JSTests/stress/private-method-check-structure-miss.js (added)
-
JSTests/stress/private-method-comparison.js (added)
-
JSTests/stress/private-method-delete-property-from-branded-structure.js (added)
-
JSTests/stress/private-method-extends-brand-check.js (added)
-
JSTests/stress/private-method-get-and-call.js (added)
-
JSTests/stress/private-method-invalid-multiple-brand-installation.js (added)
-
JSTests/stress/private-method-invalidate-compiled-with-constant-symbol.js (added)
-
JSTests/stress/private-method-nested-class.js (added)
-
JSTests/stress/private-method-on-sealed-objects.js (added)
-
JSTests/stress/private-method-on-uncacheable-dictionary.js (added)
-
JSTests/stress/private-method-polymorphic-with-constant-symbol.js (added)
-
JSTests/stress/private-method-set-brand-should-have-write-barrier.js (added)
-
JSTests/stress/private-method-untyped-use.js (added)
-
JSTests/stress/private-method-with-uncacheable-dictionary-transition.js (added)
-
JSTests/stress/private-methods-inline-cache.js (added)
-
JSTests/stress/private-methods-megamorphic-ic.js (added)
-
JSTests/stress/private-methods-on-proxy.js (added)
-
JSTests/stress/private-methods-poly-ic-multiple-classes.js (added)
-
JSTests/stress/private-methods-poly-ic-single-class.js (added)
-
JSTests/stress/private-names-available-on-direct-eval.js (added)
-
JSTests/test262/config.yaml (modified) (2 diffs)
-
Source/JavaScriptCore/CMakeLists.txt (modified) (3 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (9 diffs)
-
Source/JavaScriptCore/Sources.txt (modified) (3 diffs)
-
Source/JavaScriptCore/builtins/BuiltinExecutables.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/builtins/BuiltinExecutables.h (modified) (1 diff)
-
Source/JavaScriptCore/builtins/BuiltinNames.h (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/AccessCase.cpp (modified) (11 diffs)
-
Source/JavaScriptCore/bytecode/AccessCase.h (modified) (4 diffs)
-
Source/JavaScriptCore/bytecode/BytecodeList.rb (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.cpp (added)
-
Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.h (added)
-
Source/JavaScriptCore/bytecode/CheckPrivateBrandVariant.cpp (added)
-
Source/JavaScriptCore/bytecode/CheckPrivateBrandVariant.h (added)
-
Source/JavaScriptCore/bytecode/CodeBlock.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/ExecutableInfo.h (modified) (3 diffs)
-
Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/RecordedStatuses.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/bytecode/RecordedStatuses.h (modified) (4 diffs)
-
Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.cpp (added)
-
Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.h (added)
-
Source/JavaScriptCore/bytecode/SetPrivateBrandVariant.cpp (added)
-
Source/JavaScriptCore/bytecode/SetPrivateBrandVariant.h (added)
-
Source/JavaScriptCore/bytecode/StructureStubInfo.cpp (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/StructureStubInfo.h (modified) (3 diffs)
-
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h (modified) (2 diffs)
-
Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h (modified) (1 diff)
-
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h (modified) (6 diffs)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (modified) (15 diffs)
-
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h (modified) (12 diffs)
-
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (modified) (17 diffs)
-
Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h (modified) (5 diffs)
-
Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGCapabilities.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGClobberize.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGClobbersExitState.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGDoesGC.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGFixupPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGJITCompiler.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGJITCompiler.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGMayExit.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGNode.h (modified) (3 diffs)
-
Source/JavaScriptCore/dfg/DFGNodeType.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGSafeToExecute.h (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/dfg/DFGStoreBarrierInsertionPhase.cpp (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGVarargsForwardingPhase.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/ftl/FTLCapabilities.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/interpreter/Interpreter.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/ICStats.h (modified) (1 diff)
-
Source/JavaScriptCore/jit/JIT.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/jit/JIT.h (modified) (4 diffs)
-
Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITInlineCacheGenerator.h (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITOperations.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/jit/JITOperations.h (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITPropertyAccess.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp (modified) (1 diff)
-
Source/JavaScriptCore/jit/Repatch.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/jit/Repatch.h (modified) (2 diffs)
-
Source/JavaScriptCore/llint/LLIntSlowPaths.cpp (modified) (1 diff)
-
Source/JavaScriptCore/llint/LLIntSlowPaths.h (modified) (1 diff)
-
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm (modified) (1 diff)
-
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm (modified) (1 diff)
-
Source/JavaScriptCore/parser/Nodes.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/parser/Nodes.h (modified) (8 diffs)
-
Source/JavaScriptCore/parser/Parser.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/parser/Parser.h (modified) (5 diffs)
-
Source/JavaScriptCore/parser/ParserModes.h (modified) (1 diff)
-
Source/JavaScriptCore/parser/SyntaxChecker.h (modified) (1 diff)
-
Source/JavaScriptCore/parser/VariableEnvironment.cpp (modified) (1 diff)
-
Source/JavaScriptCore/parser/VariableEnvironment.h (modified) (13 diffs)
-
Source/JavaScriptCore/runtime/BrandedStructure.cpp (copied) (copied from trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.h) (2 diffs)
-
Source/JavaScriptCore/runtime/BrandedStructure.h (copied) (copied from trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.h) (2 diffs)
-
Source/JavaScriptCore/runtime/CachedTypes.cpp (modified) (14 diffs)
-
Source/JavaScriptCore/runtime/CodeCache.cpp (modified) (6 diffs)
-
Source/JavaScriptCore/runtime/CodeCache.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/DirectEvalExecutable.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/runtime/DirectEvalExecutable.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/EvalExecutable.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/EvalExecutable.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ExceptionHelpers.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/IndirectEvalExecutable.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSObject.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSObjectInlines.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/JSScope.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSScope.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ModuleProgramExecutable.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Options.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/OptionsList.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/ProgramExecutable.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Structure.cpp (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/Structure.h (modified) (7 diffs)
-
Source/JavaScriptCore/runtime/StructureInlines.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/StructureTransitionTable.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/SymbolTable.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/SymbolTable.h (modified) (5 diffs)
-
Source/JavaScriptCore/runtime/VM.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/VM.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r272466 r272580 1 2021-02-09 Caio Lima <ticaiolima@gmail.com> 2 3 [ESNext] Implement private methods 4 https://bugs.webkit.org/show_bug.cgi?id=194434 5 6 Reviewed by Filip Pizlo. 7 8 * stress/private-brand-installed-after-super-call-from-arrow-function.js: Added. 9 * stress/private-brand-installed-after-super-call-from-eval.js: Added. 10 * stress/private-method-brand-check.js: Added. 11 * stress/private-method-change-attribute-from-branded-structure.js: Added. 12 * stress/private-method-change-prototype-from-branded-structure.js: Added. 13 * stress/private-method-check-private-brand-ic.js: Added. 14 * stress/private-method-check-structure-miss.js: Added. 15 * stress/private-method-comparison.js: Added. 16 * stress/private-method-delete-property-from-branded-structure.js: Added. 17 * stress/private-method-extends-brand-check.js: Added. 18 * stress/private-method-get-and-call.js: Added. 19 * stress/private-method-invalid-multiple-brand-installation.js: Added. 20 * stress/private-method-invalidate-compiled-with-constant-symbol.js: Added. 21 * stress/private-method-nested-class.js: Added. 22 * stress/private-method-on-sealed-objects.js: Added. 23 * stress/private-method-on-uncacheable-dictionary.js: Added. 24 * stress/private-method-polymorphic-with-constant-symbol.js: Added. 25 * stress/private-method-set-brand-should-have-write-barrier.js: Added. 26 * stress/private-method-untyped-use.js: Added. 27 * stress/private-method-with-uncacheable-dictionary-transition.js: Added. 28 * stress/private-methods-inline-cache.js: Added. 29 * stress/private-methods-megamorphic-ic.js: Added. 30 * stress/private-methods-on-proxy.js: Added. 31 * stress/private-methods-poly-ic-multiple-classes.js: Added. 32 * stress/private-methods-poly-ic-single-class.js: Added. 33 * stress/private-names-available-on-direct-eval.js: Added. 34 * test262/config.yaml: 35 1 36 2021-02-06 Alexey Shvayka <shvaikalesh@gmail.com> 2 37 -
trunk/JSTests/test262/config.yaml
r272431 r272580 5 5 FinalizationRegistry: useWeakRefs 6 6 class-fields-private: usePrivateClassFields 7 class-methods-private: usePrivateMethods 7 8 class-static-fields-public: usePublicStaticClassFields 8 9 class-static-fields-private: usePrivateStaticClassFields … … 20 21 - legacy-regexp 21 22 22 - class-methods-private23 23 - class-static-methods-private 24 24 - cleanupSome -
trunk/Source/JavaScriptCore/CMakeLists.txt
r272170 r272580 539 539 bytecode/CallMode.h 540 540 bytecode/CallVariant.h 541 bytecode/CheckPrivateBrandStatus.h 542 bytecode/CheckPrivateBrandVariant.h 541 543 bytecode/CodeBlock.h 542 544 bytecode/CodeBlockHash.h … … 574 576 bytecode/PropertyCondition.h 575 577 bytecode/PutByIdFlags.h 578 bytecode/SetPrivateBrandStatus.h 579 bytecode/SetPrivateBrandVariant.h 576 580 bytecode/SpeculatedType.h 577 581 bytecode/StructureSet.h … … 829 833 runtime/BooleanObject.h 830 834 runtime/BooleanPrototype.h 835 runtime/BrandedStructure.h 831 836 runtime/Butterfly.h 832 837 runtime/ButterflyInlines.h -
trunk/Source/JavaScriptCore/ChangeLog
r272570 r272580 1 2021-02-09 Caio Lima <ticaiolima@gmail.com> 2 3 [ESNext] Implement private methods 4 https://bugs.webkit.org/show_bug.cgi?id=194434 5 6 Reviewed by Filip Pizlo. 7 8 This patch is adding support to private methods following the 9 specification on https://tc39.es/proposal-private-methods/. 10 This is introducing a new way to declare private methods on 11 class syntax. Private methods are only accessible within 12 classes they were declared, and only can be called from 13 objects that are instance of these classes. 14 To guarantee such rules, the proposal presents the concept of 15 Brand Check. During class evaluation, if a private method is present, 16 a `brand` is installed in this class. Every instance of such class 17 then gets this brand installed during `[[Construct]]` operation. It 18 means that an object can have multiple brands (e.g when there is also 19 private methods declared on super class). Before accessing a private 20 method, there is a check to validate if the target of the call has the 21 brand of callee method. 22 The brand check mechanism is implemented using a `@privateBrand` 23 stored on class scope. Here is a representation of how this mechanism 24 works: 25 26 ``` 27 class C { 28 #m() { return 3; } 29 method() { return this.#m(); } 30 } 31 32 let c = new C(); 33 console.log(c.method()); // prints 3 34 ``` 35 36 Generated bytecode for the following representation: 37 ``` 38 { // class lexical scope 39 const @privateBrand = @createPrivateSymbol(); 40 const #m = function () { return 3; } 41 C.prototype.method = function() { 42 @check_private_brand(this, @privateBrand); 43 return #m.call(this); 44 } 45 C = function() { 46 @set_private_brand(this, @privateBrand); 47 } 48 } 49 50 let c = new C(); 51 console.log(c.method()); // prints 3 52 ``` 53 54 # Resolving correct brand to check 55 56 In the case of shadowing or nested scope, we need to emit brand 57 checks to the right private brand. See code below: 58 59 ``` 60 class C { 61 #m() { return 3; } 62 method() { return this.#m();} 63 64 A = class { 65 #m2() { return 3; } 66 foo(o) { return o.#m(); } 67 } 68 } 69 ``` 70 71 The call of "#m" in `foo` refers to "C::#m". In such case, we need to 72 check C's private brand, instead of A's private brand. 73 To perform the proper check, we first resolve scope of "#m" and then 74 check the private brand of this scope (the scope where the private 75 method and brand are stored is the same). 76 So the bytecode to lookup the right brand is: 77 78 ``` 79 mov loc9, arg1 80 resolve_scope loc10, "#m" 81 get_from_scope loc11, loc10, "@privateBrand" 82 check_private_brand loc9, loc11 83 get_from_scope loc11, loc10, "#m" 84 // setup call frame 85 call loc11, ... 86 // ... 87 ``` 88 89 # Brand check mechanism 90 91 We are introducing in this patch 2 new bytecodes to allow brand check 92 of objects: `op_set_brand` and `op_check_brand`. 93 `op_set_brand` sets a new brand in an object, so we can perform the brand 94 check later when accessing private methods. This operations throws when 95 trying to add the same brand twice in an Object. 96 `op_check_brand` checks if the given object contains the brand we are 97 looking for. It traverses the brand chain to verify if the brand is 98 present, and throws `TypeError` otherwise. 99 100 We are also introducing a subclass for Structure called BrandedStructure. 101 It is used to store brands and to allow brand check mechanism. BrandedStructure 102 stores a brand and a parent pointer to another BrandedStructure that allow 103 us traverse the brand chain. With `BrandedStructure`, we can then 104 infer that a given object has the brand we are looking for just 105 checking its structureId. This is a very good optimization, since we can 106 reduce most of brand checks to structure checks. 107 108 We created a new kind of transition called `SetBrand` that happens when 109 `op_set_brand` is executed. This allow us to cache such kind of 110 trasitions on trasition table using the key `<brand->uid, 0, 111 TransitionKind::SetBrand>`. During this transition, we take previous 112 structure and apply one of the following rules: 113 114 1. If it's a BrandedStructure, we then set it to `m_parentBrand`, 115 to allow proper brand chain check. 116 117 2. If it's not a BrandedStructure, we set `m_parentBrand` to `nullptr`, 118 meaning that this is the first brand being added to the object 119 with this structure. 120 121 For now, we are using the flag `isBrandedStructure` to identify that a 122 given Structure is a BrandedStructure. This is done to avoid changes 123 on places where we are checking for `vm.structureStructure()`. 124 However, if we ever need space on Structure, this flag is a good 125 candidate to be deleted and we can move to a solution that uses 126 `vm.brandedStructureStructure()`; 127 128 # JIT Support 129 130 This patch also includes initial JIT support for `set_private_brand` 131 and `check_private_brand`. On Baseline JIT, we are using 132 `JITPravateBrandAccessGenerator` to support IC for both operands. 133 On `DFGByteCodeParser` we are trying to inline brand access whenever 134 possible, and fallbacking to `SetPrivateBrand` and 135 `CheckPrivateBrand` otherwise. Those nodes are not being optimized at 136 their full potential, but the code generated by them is also relying on 137 `JITPrivateBrandAccessGenerator` to have IC support for both DFG and 138 FTL. During DFG parsing, we try to reduce those access to `CheckIsConstant` 139 and `CheckStructure` (with `PutStructure` for `set_private_brand` cases) 140 based on available profiled data. This is meant to make brand checks 141 almost free on DFG/FTL tiers when we have a single evaluation of a 142 class, since the `CheckIsConstant` can be eliminated by the constant-folded 143 scope load, and the `CheckStructure` is very likely to be redundant 144 to any other `CheckStructure` that can be performed on receiver 145 when we have a finite structure set. 146 For instance, when we have a brand check on a path-of-no-return to 147 a `GetByOffset` sequence on the same receiver, the `CheckStructure` 148 for the brand check will enable CSE of the `CheckStructure` that 149 would happen for that `GetByOffset`. Such design is possible because brand 150 checks supports polymorphic access very similr to what we have for 151 `GetByOffset` sequences. 152 153 * CMakeLists.txt: 154 * JavaScriptCore.xcodeproj/project.pbxproj: 155 * Sources.txt: 156 * builtins/BuiltinExecutables.cpp: 157 (JSC::BuiltinExecutables::createDefaultConstructor): 158 (JSC::BuiltinExecutables::createExecutable): 159 * builtins/BuiltinExecutables.h: 160 161 We are adding a new parameter `PrivateBrandRequirement` to propagate 162 when a default constructor needs to emit code to setup private brand 163 on instances. 164 165 * builtins/BuiltinNames.h: 166 167 Adding `@privateBrand` that we use to store private brand on 168 class's scope. 169 170 * bytecode/AccessCase.cpp: 171 (JSC::AccessCase::createCheckPrivateBrand): 172 (JSC::AccessCase::createSetPrivateBrand): 173 (JSC::AccessCase::requiresIdentifierNameMatch const): 174 (JSC::AccessCase::requiresInt32PropertyCheck const): 175 (JSC::AccessCase::needsScratchFPR const): 176 (JSC::AccessCase::forEachDependentCell const): 177 (JSC::AccessCase::doesCalls const): 178 (JSC::AccessCase::canReplace const): 179 (JSC::AccessCase::dump const): 180 (JSC::AccessCase::generateWithGuard): 181 (JSC::AccessCase::generateImpl): 182 * bytecode/AccessCase.h: 183 (JSC::AccessCase::structure const): 184 (JSC::AccessCase::newStructure const): 185 * bytecode/BytecodeList.rb: 186 * bytecode/BytecodeUseDef.cpp: 187 (JSC::computeUsesForBytecodeIndexImpl): 188 (JSC::computeDefsForBytecodeIndexImpl): 189 * bytecode/CheckPrivateBrandStatus.cpp: Added. 190 (JSC::CheckPrivateBrandStatus::appendVariant): 191 (JSC::CheckPrivateBrandStatus::computeForBaseline): 192 (JSC::CheckPrivateBrandStatus::CheckPrivateBrandStatus): 193 (JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): 194 (JSC::CheckPrivateBrandStatus::computeFor): 195 (JSC::CheckPrivateBrandStatus::slowVersion const): 196 (JSC::CheckPrivateBrandStatus::merge): 197 (JSC::CheckPrivateBrandStatus::filter): 198 (JSC::CheckPrivateBrandStatus::singleIdentifier const): 199 (JSC::CheckPrivateBrandStatus::visitAggregate): 200 (JSC::CheckPrivateBrandStatus::markIfCheap): 201 (JSC::CheckPrivateBrandStatus::finalize): 202 (JSC::CheckPrivateBrandStatus::dump const): 203 * bytecode/CheckPrivateBrandStatus.h: Added. 204 * bytecode/CheckPrivateBrandVariant.cpp: Added. 205 (JSC::CheckPrivateBrandVariant::CheckPrivateBrandVariant): 206 (JSC::CheckPrivateBrandVariant::~CheckPrivateBrandVariant): 207 (JSC::CheckPrivateBrandVariant::attemptToMerge): 208 (JSC::CheckPrivateBrandVariant::markIfCheap): 209 (JSC::CheckPrivateBrandVariant::finalize): 210 (JSC::CheckPrivateBrandVariant::visitAggregate): 211 (JSC::CheckPrivateBrandVariant::dump const): 212 (JSC::CheckPrivateBrandVariant::dumpInContext const): 213 * bytecode/CheckPrivateBrandVariant.h: Added. 214 (JSC::CheckPrivateBrandVariant::structureSet const): 215 (JSC::CheckPrivateBrandVariant::structureSet): 216 (JSC::CheckPrivateBrandVariant::identifier const): 217 (JSC::CheckPrivateBrandVariant::overlaps): 218 * bytecode/CodeBlock.cpp: 219 (JSC::CodeBlock::finishCreation): 220 (JSC::CodeBlock::finalizeLLIntInlineCaches): 221 * bytecode/ExecutableInfo.h: 222 (JSC::ExecutableInfo::ExecutableInfo): 223 (JSC::ExecutableInfo::privateBrandRequirement const): 224 * bytecode/PolymorphicAccess.cpp: 225 (JSC::PolymorphicAccess::regenerate): 226 (WTF::printInternal): 227 * bytecode/RecordedStatuses.cpp: 228 (JSC::RecordedStatuses::operator=): 229 (JSC::RecordedStatuses::addCheckPrivateBrandStatus): 230 (JSC::RecordedStatuses::addSetPrivateBrandStatus): 231 (JSC::RecordedStatuses::visitAggregate): 232 (JSC::RecordedStatuses::markIfCheap): 233 * bytecode/RecordedStatuses.h: 234 (JSC::RecordedStatuses::forEachVector): 235 * bytecode/SetPrivateBrandStatus.cpp: Added. 236 (JSC::SetPrivateBrandStatus::appendVariant): 237 (JSC::SetPrivateBrandStatus::computeForBaseline): 238 (JSC::SetPrivateBrandStatus::SetPrivateBrandStatus): 239 (JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): 240 (JSC::SetPrivateBrandStatus::computeFor): 241 (JSC::SetPrivateBrandStatus::slowVersion const): 242 (JSC::SetPrivateBrandStatus::merge): 243 (JSC::SetPrivateBrandStatus::filter): 244 (JSC::SetPrivateBrandStatus::singleIdentifier const): 245 (JSC::SetPrivateBrandStatus::visitAggregate): 246 (JSC::SetPrivateBrandStatus::markIfCheap): 247 (JSC::SetPrivateBrandStatus::finalize): 248 (JSC::SetPrivateBrandStatus::dump const): 249 * bytecode/SetPrivateBrandStatus.h: Added. 250 * bytecode/SetPrivateBrandVariant.cpp: Added. 251 (JSC::SetPrivateBrandVariant::SetPrivateBrandVariant): 252 (JSC::SetPrivateBrandVariant::~SetPrivateBrandVariant): 253 (JSC::SetPrivateBrandVariant::attemptToMerge): 254 (JSC::SetPrivateBrandVariant::markIfCheap): 255 (JSC::SetPrivateBrandVariant::finalize): 256 (JSC::SetPrivateBrandVariant::visitAggregate): 257 (JSC::SetPrivateBrandVariant::dump const): 258 (JSC::SetPrivateBrandVariant::dumpInContext const): 259 * bytecode/SetPrivateBrandVariant.h: Added. 260 (JSC::SetPrivateBrandVariant::oldStructure const): 261 (JSC::SetPrivateBrandVariant::newStructure const): 262 (JSC::SetPrivateBrandVariant::identifier const): 263 (JSC::SetPrivateBrandVariant::overlaps): 264 * bytecode/StructureStubInfo.cpp: 265 (JSC::StructureStubInfo::reset): 266 * bytecode/StructureStubInfo.h: 267 * bytecode/UnlinkedCodeBlock.cpp: 268 (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): 269 * bytecode/UnlinkedCodeBlock.h: 270 (JSC::UnlinkedCodeBlock::privateBrandRequirement const): 271 * bytecode/UnlinkedCodeBlockGenerator.h: 272 (JSC::UnlinkedCodeBlockGenerator::privateBrandRequirement const): 273 * bytecode/UnlinkedFunctionExecutable.cpp: 274 (JSC::generateUnlinkedFunctionCodeBlock): 275 (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): 276 * bytecode/UnlinkedFunctionExecutable.h: 277 * bytecompiler/BytecodeGenerator.cpp: 278 (JSC::BytecodeGenerator::BytecodeGenerator): 279 280 We changed BytecodeGenerator for FunctionNode and EvalNode to 281 propagate parentScope PrivateNameEnvironment. These environments stores 282 private name entries that are visible into the scope of the 283 function/eval. 284 This is required to identify the kind of access a private name is 285 referring to, since it can be a private field or a private method. 286 287 (JSC::BytecodeGenerator::instantiateLexicalVariables): 288 (JSC::BytecodeGenerator::emitGetPrivateName): 289 (JSC::BytecodeGenerator::emitCreatePrivateBrand): 290 291 The process to create a private brand is as follows: 292 1. Create a PrivateSymbol using `@createPrivateSymbol`. 293 2. Store this symbol into a given scope (i.e class lexical scope) 294 on `@privateBrand` variable. 295 296 (JSC::BytecodeGenerator::emitInstallPrivateBrand): 297 (JSC::BytecodeGenerator::emitGetPrivateBrand): 298 299 We added `m_privateNamesStack` to BytecodeGenerator to represent the 300 scope chain of available private names while generating bytecode. 301 302 (JSC::BytecodeGenerator::emitCheckPrivateBrand): 303 (JSC::BytecodeGenerator::isPrivateMethod): 304 (JSC::BytecodeGenerator::pushPrivateAccessNames): 305 (JSC::BytecodeGenerator::popPrivateAccessNames): 306 (JSC::BytecodeGenerator::getAvailablePrivateAccessNames): 307 (JSC::BytecodeGenerator::emitNewDefaultConstructor): 308 (JSC::BytecodeGenerator::emitNewClassFieldInitializerFunction): 309 (JSC::BytecodeGenerator::emitDirectGetByVal): Deleted. 310 * bytecompiler/BytecodeGenerator.h: 311 (JSC::BytecodeGenerator::privateBrandRequirement const): 312 (JSC::BytecodeGenerator::generate): 313 (JSC::BytecodeGenerator::makeFunction): 314 315 This change is required to properly propagate PrivateBrandRequirement 316 to arrow functions that can potentially call `super()`. 317 318 * bytecompiler/NodesCodegen.cpp: 319 (JSC::PropertyListNode::emitDeclarePrivateFieldNames): 320 (JSC::PropertyListNode::emitBytecode): 321 (JSC::PropertyListNode::emitPutConstantProperty): 322 (JSC::BaseDotNode::emitGetPropertyValue): 323 324 Adding support to properly access private method. Since we store 325 private methods on class lexical scope, we need a different set of 326 instructions to access a private method. 327 328 (JSC::BaseDotNode::emitPutProperty): 329 330 In the case of we trying to write in a private method, we need to 331 throw a TypeError according to specification 332 (https://tc39.es/proposal-private-methods/#sec-privatefieldset). 333 334 (JSC::FunctionCallValueNode::emitBytecode): 335 (JSC::PostfixNode::emitDot): 336 (JSC::PrefixNode::emitDot): 337 (JSC::ClassExprNode::emitBytecode): 338 * debugger/DebuggerCallFrame.cpp: 339 (JSC::DebuggerCallFrame::evaluateWithScopeExtension): 340 * dfg/DFGAbstractInterpreterInlines.h: 341 (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): 342 (JSC::DFG::AbstractInterpreter<AbstractStateType>::filterICStatus): 343 * dfg/DFGArgumentsEliminationPhase.cpp: 344 * dfg/DFGByteCodeParser.cpp: 345 (JSC::DFG::ByteCodeParser::parseBlock): 346 * dfg/DFGCapabilities.cpp: 347 (JSC::DFG::capabilityLevel): 348 * dfg/DFGClobberize.h: 349 (JSC::DFG::clobberize): 350 * dfg/DFGClobbersExitState.cpp: 351 (JSC::DFG::clobbersExitState): 352 * dfg/DFGDoesGC.cpp: 353 (JSC::DFG::doesGC): 354 * dfg/DFGFixupPhase.cpp: 355 (JSC::DFG::FixupPhase::fixupNode): 356 * dfg/DFGGraph.h: 357 * dfg/DFGJITCompiler.cpp: 358 (JSC::DFG::JITCompiler::link): 359 * dfg/DFGJITCompiler.h: 360 (JSC::DFG::JITCompiler::addPrivateBrandAccess): 361 * dfg/DFGMayExit.cpp: 362 * dfg/DFGNode.h: 363 (JSC::DFG::Node::hasCheckPrivateBrandStatus): 364 (JSC::DFG::Node::checkPrivateBrandStatus): 365 (JSC::DFG::Node::hasSetPrivateBrandStatus): 366 (JSC::DFG::Node::setPrivateBrandStatus): 367 * dfg/DFGNodeType.h: 368 * dfg/DFGObjectAllocationSinkingPhase.cpp: 369 * dfg/DFGPredictionPropagationPhase.cpp: 370 * dfg/DFGSafeToExecute.h: 371 (JSC::DFG::safeToExecute): 372 * dfg/DFGSpeculativeJIT.cpp: 373 (JSC::DFG::SpeculativeJIT::compileCheckPrivateBrand): 374 (JSC::DFG::SpeculativeJIT::compileSetPrivateBrand): 375 * dfg/DFGSpeculativeJIT.h: 376 * dfg/DFGSpeculativeJIT32_64.cpp: 377 (JSC::DFG::SpeculativeJIT::compile): 378 * dfg/DFGSpeculativeJIT64.cpp: 379 (JSC::DFG::SpeculativeJIT::compile): 380 * dfg/DFGStoreBarrierInsertionPhase.cpp: 381 * dfg/DFGVarargsForwardingPhase.cpp: 382 * ftl/FTLCapabilities.cpp: 383 (JSC::FTL::canCompile): 384 * ftl/FTLLowerDFGToB3.cpp: 385 (JSC::FTL::DFG::LowerDFGToB3::compileNode): 386 (JSC::FTL::DFG::LowerDFGToB3::compilePrivateBrandAccess): 387 (JSC::FTL::DFG::LowerDFGToB3::compileCheckPrivateBrand): 388 (JSC::FTL::DFG::LowerDFGToB3::compileSetPrivateBrand): 389 * interpreter/Interpreter.cpp: 390 (JSC::eval): 391 * jit/JIT.cpp: 392 (JSC::JIT::privateCompileMainPass): 393 (JSC::JIT::privateCompileSlowCases): 394 (JSC::JIT::link): 395 * jit/JIT.h: 396 * jit/JITInlineCacheGenerator.cpp: 397 (JSC::JITPrivateBrandAccessGenerator::JITPrivateBrandAccessGenerator): 398 (JSC::JITPrivateBrandAccessGenerator::generateFastPath): 399 (JSC::JITPrivateBrandAccessGenerator::finalize): 400 * jit/JITInlineCacheGenerator.h: 401 (JSC::JITPrivateBrandAccessGenerator::JITPrivateBrandAccessGenerator): 402 (JSC::JITPrivateBrandAccessGenerator::slowPathJump const): 403 * jit/JITOperations.cpp: 404 (JSC::JSC_DEFINE_JIT_OPERATION): 405 (JSC::getPrivateName): 406 * jit/JITOperations.h: 407 * jit/JITPropertyAccess.cpp: 408 (JSC::JIT::emit_op_set_private_brand): 409 (JSC::JIT::emitSlow_op_set_private_brand): 410 (JSC::JIT::emit_op_check_private_brand): 411 (JSC::JIT::emitSlow_op_check_private_brand): 412 * jit/JITPropertyAccess32_64.cpp: 413 (JSC::JIT::emit_op_set_private_brand): 414 (JSC::JIT::emitSlow_op_set_private_brand): 415 (JSC::JIT::emit_op_check_private_brand): 416 (JSC::JIT::emitSlow_op_check_private_brand): 417 * jit/Repatch.cpp: 418 (JSC::tryCacheCheckPrivateBrand): 419 (JSC::repatchCheckPrivateBrand): 420 (JSC::tryCacheSetPrivateBrand): 421 (JSC::repatchSetPrivateBrand): 422 (JSC::resetCheckPrivateBrand): 423 (JSC::resetSetPrivateBrand): 424 * jit/Repatch.h: 425 * llint/LLIntSlowPaths.cpp: 426 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 427 * llint/LLIntSlowPaths.h: 428 * llint/LowLevelInterpreter32_64.asm: 429 * llint/LowLevelInterpreter64.asm: 430 * parser/Nodes.cpp: 431 (JSC::FunctionMetadataNode::FunctionMetadataNode): 432 * parser/Nodes.h: 433 (JSC::BaseDotNode::isPrivateMember const): 434 (JSC::BaseDotNode::isPrivateField const): Deleted. 435 * parser/Parser.cpp: 436 (JSC::Parser<LexerType>::parseClass): 437 (JSC::Parser<LexerType>::parseMemberExpression): 438 * parser/Parser.h: 439 (JSC::Scope::declarePrivateMethod): 440 (JSC::Scope::declarePrivateField): 441 (JSC::Parser<LexerType>::parse): 442 (JSC::parse): 443 (JSC::Scope::declarePrivateName): Deleted. 444 * parser/ParserModes.h: 445 * parser/SyntaxChecker.h: 446 (JSC::SyntaxChecker::createDotAccess): 447 * parser/VariableEnvironment.cpp: 448 (JSC::VariableEnvironment::declarePrivateMethod): 449 * parser/VariableEnvironment.h: 450 (JSC::VariableEnvironmentEntry::isPrivateField const): 451 (JSC::VariableEnvironmentEntry::isPrivateMethod const): 452 (JSC::VariableEnvironmentEntry::setIsPrivateField): 453 (JSC::VariableEnvironmentEntry::setIsPrivateMethod): 454 (JSC::PrivateNameEntry::isMethod const): 455 (JSC::PrivateNameEntry::isPrivateMethodOrAcessor const): 456 (JSC::VariableEnvironment::addPrivateName): 457 (JSC::VariableEnvironment::declarePrivateField): 458 (JSC::VariableEnvironment::declarePrivateMethod): 459 (JSC::VariableEnvironment::privateNameEnvironment const): 460 (JSC::VariableEnvironment::hasPrivateMethodOrAccessor const): 461 (JSC::VariableEnvironment::addPrivateNamesFrom): 462 (JSC::VariableEnvironmentEntry::isPrivateName const): Deleted. 463 (JSC::VariableEnvironmentEntry::setIsPrivateName): Deleted. 464 (JSC::VariableEnvironment::declarePrivateName): Deleted. 465 * runtime/CachedTypes.cpp: 466 (JSC::CachedCodeBlockRareData::encode): 467 (JSC::CachedCodeBlockRareData::decode const): 468 (JSC::CachedFunctionExecutableRareData::encode): 469 (JSC::CachedFunctionExecutableRareData::decode const): 470 (JSC::CachedFunctionExecutable::privateBrandRequirement const): 471 (JSC::CachedCodeBlock::derivedContextType const): 472 (JSC::CachedFunctionExecutable::encode): 473 (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): 474 (JSC::CachedCodeBlock::needsClassFieldInitializer const): Deleted. 475 * runtime/CodeCache.cpp: 476 (JSC::generateUnlinkedCodeBlockImpl): 477 (JSC::generateUnlinkedCodeBlock): 478 (JSC::generateUnlinkedCodeBlockForDirectEval): 479 (JSC::CodeCache::getUnlinkedGlobalFunctionExecutable): 480 * runtime/CodeCache.h: 481 * runtime/DirectEvalExecutable.cpp: 482 (JSC::DirectEvalExecutable::create): 483 (JSC::DirectEvalExecutable::DirectEvalExecutable): 484 * runtime/DirectEvalExecutable.h: 485 * runtime/EvalExecutable.cpp: 486 (JSC::EvalExecutable::EvalExecutable): 487 * runtime/EvalExecutable.h: 488 (JSC::EvalExecutable::executableInfo const): 489 (JSC::EvalExecutable::privateBrandRequirement const): 490 * runtime/ExceptionHelpers.cpp: 491 (JSC::createInvalidPrivateNameError): 492 * runtime/IndirectEvalExecutable.cpp: 493 (JSC::IndirectEvalExecutable::IndirectEvalExecutable): 494 * runtime/JSObject.h: 495 * runtime/JSObjectInlines.h: 496 (JSC::JSObject::checkPrivateBrand): 497 (JSC::JSObject::setPrivateBrand): 498 * runtime/JSScope.cpp: 499 (JSC::JSScope::collectClosureVariablesUnderTDZ): 500 * runtime/JSScope.h: 501 * runtime/ModuleProgramExecutable.h: 502 * runtime/Options.cpp: 503 (JSC::Options::recomputeDependentOptions): 504 * runtime/OptionsList.h: 505 * runtime/ProgramExecutable.h: 506 * runtime/Structure.cpp: 507 (JSC::Structure::materializePropertyTable): 508 (JSC::BrandedStructure::BrandedStructure): 509 (JSC::BrandedStructure::create): 510 (JSC::BrandedStructure::checkBrand): 511 (JSC::Structure::setBrandTransitionFromExistingStructureImpl): 512 (JSC::Structure::setBrandTransitionFromExistingStructureConcurrently): 513 (JSC::Structure::setBrandTransition): 514 * runtime/Structure.h: 515 (JSC::Structure::finishCreation): 516 * runtime/StructureInlines.h: 517 (JSC::Structure::create): 518 (JSC::Structure::forEachPropertyConcurrently): 519 * runtime/StructureTransitionTable.h: 520 * runtime/SymbolTable.cpp: 521 (JSC::SymbolTable::cloneScopePart): 522 * runtime/SymbolTable.h: 523 * runtime/VM.cpp: 524 (JSC::VM::VM): 525 * runtime/VM.h: 526 1 527 2021-02-09 Yusuke Suzuki <ysuzuki@apple.com> 2 528 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r272222 r272580 1243 1243 86158AB3155C8B4000B45C9C /* PropertyName.h in Headers */ = {isa = PBXBuildFile; fileRef = 86158AB2155C8B3F00B45C9C /* PropertyName.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1244 1244 861816771FB7924200ECC4EC /* BigIntObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 861816761FB7922F00ECC4EC /* BigIntObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1245 861AF60725D18C9D000B63E1 /* BrandedStructure.h in Headers */ = {isa = PBXBuildFile; fileRef = 861AF60625D18C9D000B63E1 /* BrandedStructure.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1245 1246 862553D216136E1A009F17D0 /* JSProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 862553CF16136AA5009F17D0 /* JSProxy.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1247 86281EF025B6160000367004 /* CheckPrivateBrandVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 86281EEF25B6160000367004 /* CheckPrivateBrandVariant.h */; }; 1248 86281EF425B61AF000367004 /* CheckPrivateBrandStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 86281EF325B61AF000367004 /* CheckPrivateBrandStatus.h */; }; 1246 1249 863B23E00FC6118900703AA4 /* MacroAssemblerCodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1247 1250 863FBC5A25B093B900F6C930 /* WasmValueLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 863FBC5825B093B900F6C930 /* WasmValueLocation.h */; }; 1248 1251 865A30F1135007E100CDB49E /* JSCJSValueInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 865A30F0135007E100CDB49E /* JSCJSValueInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1252 865DA0C525B8957400875772 /* SetPrivateBrandVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 865DA0C425B8957400875772 /* SetPrivateBrandVariant.h */; }; 1253 865DA0C825B8960C00875772 /* SetPrivateBrandStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = 865DA0C725B8960C00875772 /* SetPrivateBrandStatus.h */; }; 1249 1254 866739D213BFDE710023D87C /* BigInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 866739D013BFDE710023D87C /* BigInteger.h */; }; 1250 1255 866739D313BFDE710023D87C /* Uint16WithFraction.h in Headers */ = {isa = PBXBuildFile; fileRef = 866739D113BFDE710023D87C /* Uint16WithFraction.h */; }; … … 4141 4146 861816761FB7922F00ECC4EC /* BigIntObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BigIntObject.h; sourceTree = "<group>"; }; 4142 4147 861816781FB7931300ECC4EC /* BigIntObject.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BigIntObject.cpp; sourceTree = "<group>"; }; 4148 861AF60625D18C9D000B63E1 /* BrandedStructure.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BrandedStructure.h; sourceTree = "<group>"; }; 4143 4149 862553CE16136AA5009F17D0 /* JSProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSProxy.cpp; sourceTree = "<group>"; }; 4144 4150 862553CF16136AA5009F17D0 /* JSProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSProxy.h; sourceTree = "<group>"; }; 4151 86281EEF25B6160000367004 /* CheckPrivateBrandVariant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CheckPrivateBrandVariant.h; sourceTree = "<group>"; }; 4152 86281EF125B6165E00367004 /* CheckPrivateBrandVariant.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CheckPrivateBrandVariant.cpp; sourceTree = "<group>"; }; 4153 86281EF325B61AF000367004 /* CheckPrivateBrandStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CheckPrivateBrandStatus.h; sourceTree = "<group>"; }; 4154 86281EF525B61B0600367004 /* CheckPrivateBrandStatus.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CheckPrivateBrandStatus.cpp; sourceTree = "<group>"; }; 4145 4155 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerCodeRef.h; sourceTree = "<group>"; }; 4146 4156 863C6D981521111200585E4E /* YarrCanonicalizeUCS2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = YarrCanonicalizeUCS2.cpp; path = yarr/YarrCanonicalizeUCS2.cpp; sourceTree = "<group>"; }; … … 4153 4163 8640923C156EED3B00566CB2 /* MacroAssemblerARM64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerARM64.h; sourceTree = "<group>"; }; 4154 4164 865A30F0135007E100CDB49E /* JSCJSValueInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCJSValueInlines.h; sourceTree = "<group>"; }; 4165 865DA0C425B8957400875772 /* SetPrivateBrandVariant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SetPrivateBrandVariant.h; sourceTree = "<group>"; }; 4166 865DA0C625B8959E00875772 /* SetPrivateBrandVariant.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SetPrivateBrandVariant.cpp; sourceTree = "<group>"; }; 4167 865DA0C725B8960C00875772 /* SetPrivateBrandStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SetPrivateBrandStatus.h; sourceTree = "<group>"; }; 4168 865DA0C925B8962A00875772 /* SetPrivateBrandStatus.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SetPrivateBrandStatus.cpp; sourceTree = "<group>"; }; 4169 8664967A25D1DD1200516B36 /* BrandedStructure.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BrandedStructure.cpp; sourceTree = "<group>"; }; 4155 4170 866739D013BFDE710023D87C /* BigInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BigInteger.h; sourceTree = "<group>"; }; 4156 4171 866739D113BFDE710023D87C /* Uint16WithFraction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Uint16WithFraction.h; sourceTree = "<group>"; }; … … 7157 7172 BC7952340E15EB5600A898AB /* BooleanPrototype.cpp */, 7158 7173 BC7952350E15EB5600A898AB /* BooleanPrototype.h */, 7174 8664967A25D1DD1200516B36 /* BrandedStructure.cpp */, 7175 861AF60625D18C9D000B63E1 /* BrandedStructure.h */, 7159 7176 9E72940A190F0514001A91B5 /* BundlePath.h */, 7160 7177 9E729409190F0306001A91B5 /* BundlePath.mm */, … … 8417 8434 0F3B7E2419A11B8000D9BC56 /* CallVariant.cpp */, 8418 8435 0F3B7E2519A11B8000D9BC56 /* CallVariant.h */, 8436 86281EF525B61B0600367004 /* CheckPrivateBrandStatus.cpp */, 8437 86281EF325B61AF000367004 /* CheckPrivateBrandStatus.h */, 8438 86281EF125B6165E00367004 /* CheckPrivateBrandVariant.cpp */, 8439 86281EEF25B6160000367004 /* CheckPrivateBrandVariant.h */, 8419 8440 969A07900ED1D3AE00F1F681 /* CodeBlock.cpp */, 8420 8441 969A07910ED1D3AE00F1F681 /* CodeBlock.h */, … … 8551 8572 0FF60ABF16740F8100029779 /* ReduceWhitespace.cpp */, 8552 8573 0FF60AC016740F8100029779 /* ReduceWhitespace.h */, 8574 865DA0C925B8962A00875772 /* SetPrivateBrandStatus.cpp */, 8575 865DA0C725B8960C00875772 /* SetPrivateBrandStatus.h */, 8576 865DA0C625B8959E00875772 /* SetPrivateBrandVariant.cpp */, 8577 865DA0C425B8957400875772 /* SetPrivateBrandVariant.h */, 8553 8578 0FD82E84141F3FDA00179C94 /* SpeculatedType.cpp */, 8554 8579 0FD82E4F141DAEA100179C94 /* SpeculatedType.h */, … … 9277 9302 9B4694391F97439E00CCB3F9 /* BooleanPrototype.h in Headers */, 9278 9303 996B73191BDA068000331B84 /* BooleanPrototype.lut.h in Headers */, 9304 861AF60725D18C9D000B63E1 /* BrandedStructure.h in Headers */, 9279 9305 FEA08620182B7A0400F6D851 /* Breakpoint.h in Headers */, 9280 9306 DE26E9031CB5DD0500D2BE82 /* BuiltinExecutableCreator.h in Headers */, … … 9342 9368 0F1C3DDA1BBCE09E00E523E4 /* CellState.h in Headers */, 9343 9369 5338E2A72396EFFB00C61BAD /* CheckpointOSRExitSideState.h in Headers */, 9370 86281EF425B61AF000367004 /* CheckPrivateBrandStatus.h in Headers */, 9371 86281EF025B6160000367004 /* CheckPrivateBrandVariant.h in Headers */, 9344 9372 BC6AAAE50E1F426500AD87D8 /* ClassInfo.h in Headers */, 9345 9373 0FE050261AA9095600D33B33 /* ClonedArguments.h in Headers */, … … 10393 10421 A7299DA617D12858005F5FF9 /* SetConstructor.h in Headers */, 10394 10422 A790DD6E182F499700588807 /* SetIteratorPrototype.h in Headers */, 10423 865DA0C825B8960C00875772 /* SetPrivateBrandStatus.h in Headers */, 10424 865DA0C525B8957400875772 /* SetPrivateBrandVariant.h in Headers */, 10395 10425 A7299DA217D12848005F5FF9 /* SetPrototype.h in Headers */, 10396 10426 0FEE98411A8865B700754E93 /* SetupVarargsFrame.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r271993 r272580 212 212 bytecode/CallMode.cpp 213 213 bytecode/CallVariant.cpp 214 bytecode/CheckPrivateBrandStatus.cpp 215 bytecode/CheckPrivateBrandVariant.cpp 214 216 bytecode/CodeBlock.cpp 215 217 bytecode/CodeBlockHash.cpp … … 272 274 bytecode/RecordedStatuses.cpp 273 275 bytecode/ReduceWhitespace.cpp 276 bytecode/SetPrivateBrandStatus.cpp 277 bytecode/SetPrivateBrandVariant.cpp 274 278 bytecode/SpeculatedType.cpp 275 279 bytecode/StructureSet.cpp … … 735 739 runtime/BooleanObject.cpp 736 740 runtime/BooleanPrototype.cpp 741 runtime/BrandedStructure.cpp 737 742 runtime/BytecodeCacheError.cpp 738 743 runtime/CallData.cpp -
trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
r270870 r272580 60 60 } 61 61 62 UnlinkedFunctionExecutable* BuiltinExecutables::createDefaultConstructor(ConstructorKind constructorKind, const Identifier& name, NeedsClassFieldInitializer needsClassFieldInitializer )62 UnlinkedFunctionExecutable* BuiltinExecutables::createDefaultConstructor(ConstructorKind constructorKind, const Identifier& name, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement) 63 63 { 64 64 switch (constructorKind) { … … 68 68 case ConstructorKind::Base: 69 69 case ConstructorKind::Extends: 70 return createExecutable(m_vm, defaultConstructorSourceCode(constructorKind), name, constructorKind, ConstructAbility::CanConstruct, needsClassFieldInitializer );70 return createExecutable(m_vm, defaultConstructorSourceCode(constructorKind), name, constructorKind, ConstructAbility::CanConstruct, needsClassFieldInitializer, privateBrandRequirement); 71 71 } 72 72 ASSERT_NOT_REACHED(); … … 79 79 } 80 80 81 UnlinkedFunctionExecutable* BuiltinExecutables::createExecutable(VM& vm, const SourceCode& source, const Identifier& name, ConstructorKind constructorKind, ConstructAbility constructAbility, NeedsClassFieldInitializer needsClassFieldInitializer )81 UnlinkedFunctionExecutable* BuiltinExecutables::createExecutable(VM& vm, const SourceCode& source, const Identifier& name, ConstructorKind constructorKind, ConstructAbility constructAbility, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement) 82 82 { 83 83 // FIXME: Can we just make MetaData computation be constexpr and have the compiler do this for us? … … 252 252 } 253 253 254 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(vm, source, &metadata, kind, constructAbility, JSParserScriptMode::Classic, nullptr, DerivedContextType::None, needsClassFieldInitializer, isBuiltinDefaultClassConstructor);254 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(vm, source, &metadata, kind, constructAbility, JSParserScriptMode::Classic, nullptr, WTF::nullopt, DerivedContextType::None, needsClassFieldInitializer, privateBrandRequirement, isBuiltinDefaultClassConstructor); 255 255 return functionExecutable; 256 256 } -
trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.h
r254653 r272580 59 59 60 60 static SourceCode defaultConstructorSourceCode(ConstructorKind); 61 UnlinkedFunctionExecutable* createDefaultConstructor(ConstructorKind, const Identifier& name, NeedsClassFieldInitializer );61 UnlinkedFunctionExecutable* createDefaultConstructor(ConstructorKind, const Identifier& name, NeedsClassFieldInitializer, PrivateBrandRequirement); 62 62 63 static UnlinkedFunctionExecutable* createExecutable(VM&, const SourceCode&, const Identifier&, ConstructorKind, ConstructAbility, NeedsClassFieldInitializer );63 static UnlinkedFunctionExecutable* createExecutable(VM&, const SourceCode&, const Identifier&, ConstructorKind, ConstructAbility, NeedsClassFieldInitializer, PrivateBrandRequirement = PrivateBrandRequirement::None); 64 64 65 65 void finalizeUnconditionally(); -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r272364 r272580 174 174 macro(webAssemblyInstantiateStreamingInternal) \ 175 175 macro(instanceFieldInitializer) \ 176 macro(privateBrand) \ 176 177 macro(hasOwnPropertyFunction) \ 177 178 macro(createPrivateSymbol) \ -
trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp
r272174 r272580 134 134 } 135 135 136 std::unique_ptr<AccessCase> AccessCase::createCheckPrivateBrand(VM& vm, JSCell* owner, CacheableIdentifier identifier, Structure* structure) 137 { 138 return std::unique_ptr<AccessCase>(new AccessCase(vm, owner, CheckPrivateBrand, identifier, invalidOffset, structure, { }, { })); 139 } 140 141 std::unique_ptr<AccessCase> AccessCase::createSetPrivateBrand( 142 VM& vm, JSCell* owner, CacheableIdentifier identifier, Structure* oldStructure, Structure* newStructure) 143 { 144 RELEASE_ASSERT(oldStructure == newStructure->previousID()); 145 return std::unique_ptr<AccessCase>(new AccessCase(vm, owner, SetPrivateBrand, identifier, invalidOffset, newStructure, { }, { })); 146 } 147 136 148 AccessCase::~AccessCase() 137 149 { … … 293 305 case ScopedArgumentsLength: 294 306 case ModuleNamespaceLoad: 307 case CheckPrivateBrand: 308 case SetPrivateBrand: 295 309 return true; 296 310 case InstanceOfHit: … … 346 360 case InstanceOfMiss: 347 361 case InstanceOfGeneric: 362 case CheckPrivateBrand: 363 case SetPrivateBrand: 348 364 return false; 349 365 case IndexedInt32Load: … … 388 404 case InHit: 389 405 case InMiss: 406 case CheckPrivateBrand: 407 case SetPrivateBrand: 390 408 case ArrayLength: 391 409 case StringLength: … … 475 493 case InHit: 476 494 case InMiss: 495 case CheckPrivateBrand: 496 case SetPrivateBrand: 477 497 case ArrayLength: 478 498 case StringLength: … … 524 544 case InHit: 525 545 case InMiss: 546 case CheckPrivateBrand: 547 case SetPrivateBrand: 526 548 case ArrayLength: 527 549 case StringLength: … … 675 697 case InHit: 676 698 case InMiss: 699 case CheckPrivateBrand: 700 case SetPrivateBrand: 677 701 if (other.type() != type()) 678 702 return false; … … 706 730 m_polyProtoAccessChain->dump(structure(), out); 707 731 } else { 708 if (m_type == Transition || m_type == Delete )732 if (m_type == Transition || m_type == Delete || m_type == SetPrivateBrand) 709 733 out.print(comma, "structure = ", pointerDump(structure()), " -> ", pointerDump(newStructure())); 710 734 else if (m_structure) … … 1335 1359 } else 1336 1360 state.failAndIgnore.append(failAndIgnore); 1361 return; 1362 } 1363 1364 case CheckPrivateBrand: { 1365 emitDefaultGuard(); 1366 state.succeed(); 1337 1367 return; 1338 1368 } … … 2039 2069 } 2040 2070 2071 case SetPrivateBrand: { 2072 ASSERT(structure()->transitionWatchpointSetHasBeenInvalidated()); 2073 ASSERT(newStructure()->transitionKind() == TransitionKind::SetBrand); 2074 2075 uint32_t structureBits = bitwise_cast<uint32_t>(newStructure()->id()); 2076 jit.store32( 2077 CCallHelpers::TrustedImm32(structureBits), 2078 CCallHelpers::Address(baseGPR, JSCell::structureIDOffset())); 2079 2080 state.succeed(); 2081 return; 2082 } 2083 2041 2084 case DeleteNonConfigurable: { 2042 2085 jit.move(MacroAssembler::TrustedImm32(false), valueRegs.payloadGPR()); … … 2112 2155 case IndexedTypedArrayFloat64Load: 2113 2156 case IndexedStringLoad: 2157 case CheckPrivateBrand: 2114 2158 // These need to be handled by generateWithGuard(), since the guard is part of the 2115 2159 // algorithm. We can be sure that nobody will call generate() directly for these since they -
trunk/Source/JavaScriptCore/bytecode/AccessCase.h
r259463 r272580 109 109 InstanceOfMiss, 110 110 InstanceOfGeneric, 111 CheckPrivateBrand, 112 SetPrivateBrand, 111 113 IndexedInt32Load, 112 114 IndexedDoubleLoad, … … 154 156 static std::unique_ptr<AccessCase> createDelete(VM&, JSCell* owner, CacheableIdentifier, PropertyOffset, Structure* oldStructure, 155 157 Structure* newStructure); 158 159 static std::unique_ptr<AccessCase> createCheckPrivateBrand(VM&, JSCell* owner, CacheableIdentifier, Structure*); 160 static std::unique_ptr<AccessCase> createSetPrivateBrand(VM&, JSCell* owner, CacheableIdentifier, Structure* oldStructure, Structure* newStructure); 156 161 157 162 static std::unique_ptr<AccessCase> fromStructureStubInfo(VM&, JSCell* owner, CacheableIdentifier, StructureStubInfo&); … … 163 168 Structure* structure() const 164 169 { 165 if (m_type == Transition || m_type == Delete )170 if (m_type == Transition || m_type == Delete || m_type == SetPrivateBrand) 166 171 return m_structure->previousID(); 167 172 return m_structure.get(); … … 171 176 Structure* newStructure() const 172 177 { 173 ASSERT(m_type == Transition || m_type == Delete );178 ASSERT(m_type == Transition || m_type == Delete || m_type == SetPrivateBrand); 174 179 return m_structure.get(); 175 180 } -
trunk/Source/JavaScriptCore/bytecode/BytecodeList.rb
r270948 r272580 588 588 newStructureID: StructureID, 589 589 } 590 591 op :set_private_brand, 592 args: { 593 base: VirtualRegister, 594 brand: VirtualRegister, 595 }, 596 metadata: { 597 oldStructureID: StructureID, 598 newStructureID: StructureID, 599 brand: WriteBarrier[JSCell], 600 } 601 602 op :check_private_brand, 603 args: { 604 base: VirtualRegister, 605 brand: VirtualRegister, 606 }, 607 metadata: { 608 structureID: StructureID, 609 brand: WriteBarrier[JSCell], 610 } 611 590 612 591 613 op :put_by_val, -
trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.cpp
r270874 r272580 230 230 USES(OpGetPrivateName, base, property) 231 231 USES(OpPutPrivateName, base, property, value) 232 USES(OpSetPrivateBrand, base, brand) 233 USES(OpCheckPrivateBrand, base, brand) 232 234 USES(OpInByVal, base, property) 233 235 USES(OpOverridesHasInstance, constructor, hasInstanceValue) … … 398 400 case op_put_by_val_direct: 399 401 case op_put_private_name: 402 case op_set_private_brand: 403 case op_check_private_brand: 400 404 case op_put_internal_field: 401 405 case op_define_data_property: -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r270874 r272580 545 545 LINK(OpPutPrivateName) 546 546 547 LINK(OpSetPrivateBrand) 548 LINK(OpCheckPrivateBrand) 549 547 550 LINK(OpNewArray) 548 551 LINK(OpNewArrayWithSize) … … 1337 1340 metadata.m_newStructureID = 0; 1338 1341 metadata.m_property.clear(); 1342 }); 1343 1344 m_metadata->forEach<OpSetPrivateBrand>([&] (auto& metadata) { 1345 StructureID oldStructureID = metadata.m_oldStructureID; 1346 StructureID newStructureID = metadata.m_newStructureID; 1347 JSCell* brand = metadata.m_brand.get(); 1348 if ((!oldStructureID || vm.heap.isMarked(vm.heap.structureIDTable().get(oldStructureID))) 1349 && (!brand || vm.heap.isMarked(brand)) 1350 && (!newStructureID || vm.heap.isMarked(vm.heap.structureIDTable().get(newStructureID)))) 1351 return; 1352 1353 dataLogLnIf(Options::verboseOSR(), "Clearing LLInt set_private_brand transition."); 1354 metadata.m_oldStructureID = 0; 1355 metadata.m_newStructureID = 0; 1356 metadata.m_brand.clear(); 1357 }); 1358 1359 m_metadata->forEach<OpCheckPrivateBrand>([&] (auto& metadata) { 1360 StructureID structureID = metadata.m_structureID; 1361 JSCell* brand = metadata.m_brand.get(); 1362 if ((!structureID || vm.heap.isMarked(vm.heap.structureIDTable().get(structureID))) 1363 && (!brand || vm.heap.isMarked(brand))) 1364 return; 1365 1366 dataLogLnIf(Options::verboseOSR(), "Clearing LLInt set_private_brand transition."); 1367 metadata.m_structureID = 0; 1368 metadata.m_brand.clear(); 1339 1369 }); 1340 1370 -
trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h
r259676 r272580 37 37 // https://bugs.webkit.org/show_bug.cgi?id=151547 38 38 struct ExecutableInfo { 39 ExecutableInfo(bool usesEval, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, JSParserScriptMode scriptMode, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isClassContext, EvalContextType evalContextType)39 ExecutableInfo(bool usesEval, bool isConstructor, PrivateBrandRequirement privateBrandRequirement, bool isBuiltinFunction, ConstructorKind constructorKind, JSParserScriptMode scriptMode, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isClassContext, EvalContextType evalContextType) 40 40 : m_usesEval(usesEval) 41 41 , m_isConstructor(isConstructor) 42 , m_privateBrandRequirement(static_cast<unsigned>(privateBrandRequirement)) 42 43 , m_isBuiltinFunction(isBuiltinFunction) 43 44 , m_constructorKind(static_cast<unsigned>(constructorKind)) … … 58 59 bool usesEval() const { return m_usesEval; } 59 60 bool isConstructor() const { return m_isConstructor; } 61 PrivateBrandRequirement privateBrandRequirement() const { return static_cast<PrivateBrandRequirement>(m_privateBrandRequirement); } 60 62 bool isBuiltinFunction() const { return m_isBuiltinFunction; } 61 63 ConstructorKind constructorKind() const { return static_cast<ConstructorKind>(m_constructorKind); } … … 72 74 unsigned m_usesEval : 1; 73 75 unsigned m_isConstructor : 1; 76 unsigned m_privateBrandRequirement : 1; 74 77 unsigned m_isBuiltinFunction : 1; 75 78 unsigned m_constructorKind : 2; -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp
r265997 r272580 470 470 if (state.u.thisGPR != InvalidGPRReg) 471 471 allocator.lock(state.u.thisGPR); 472 allocator.lock(state.valueRegs); 472 if (state.valueRegs) 473 allocator.lock(state.valueRegs); 473 474 #if USE(JSVALUE32_64) 474 475 allocator.lock(stubInfo.baseTagGPR); … … 853 854 out.print("InMiss"); 854 855 return; 856 case AccessCase::CheckPrivateBrand: 857 out.print("CheckPrivateBrand"); 858 return; 859 case AccessCase::SetPrivateBrand: 860 out.print("SetPrivateBrand"); 861 return; 855 862 case AccessCase::ArrayLength: 856 863 out.print("ArrayLength"); -
trunk/Source/JavaScriptCore/bytecode/RecordedStatuses.cpp
r259583 r272580 36 36 ins = WTFMove(other.ins); 37 37 deletes = WTFMove(other.deletes); 38 checkPrivateBrands = WTFMove(other.checkPrivateBrands); 39 setPrivateBrands = WTFMove(other.setPrivateBrands); 38 40 shrinkToFit(); 39 41 return *this; … … 85 87 } 86 88 89 CheckPrivateBrandStatus* RecordedStatuses::addCheckPrivateBrandStatus(const CodeOrigin& codeOrigin, const CheckPrivateBrandStatus& status) 90 { 91 auto statusPtr = makeUnique<CheckPrivateBrandStatus>(status); 92 CheckPrivateBrandStatus* result = statusPtr.get(); 93 checkPrivateBrands.append(std::make_pair(codeOrigin, WTFMove(statusPtr))); 94 return result; 95 } 96 97 SetPrivateBrandStatus* RecordedStatuses::addSetPrivateBrandStatus(const CodeOrigin& codeOrigin, const SetPrivateBrandStatus& status) 98 { 99 auto statusPtr = makeUnique<SetPrivateBrandStatus>(status); 100 SetPrivateBrandStatus* result = statusPtr.get(); 101 setPrivateBrands.append(std::make_pair(codeOrigin, WTFMove(statusPtr))); 102 return result; 103 } 104 87 105 void RecordedStatuses::visitAggregate(SlotVisitor& slotVisitor) 88 106 { … … 90 108 pair.second->visitAggregate(slotVisitor); 91 109 for (auto& pair : deletes) 110 pair.second->visitAggregate(slotVisitor); 111 for (auto& pair : checkPrivateBrands) 112 pair.second->visitAggregate(slotVisitor); 113 for (auto& pair : setPrivateBrands) 92 114 pair.second->visitAggregate(slotVisitor); 93 115 } … … 102 124 pair.second->markIfCheap(slotVisitor); 103 125 for (auto& pair : deletes) 126 pair.second->markIfCheap(slotVisitor); 127 for (auto& pair : checkPrivateBrands) 128 pair.second->markIfCheap(slotVisitor); 129 for (auto& pair : setPrivateBrands) 104 130 pair.second->markIfCheap(slotVisitor); 105 131 } -
trunk/Source/JavaScriptCore/bytecode/RecordedStatuses.h
r259583 r272580 27 27 28 28 #include "CallLinkStatus.h" 29 #include "CheckPrivateBrandStatus.h" 29 30 #include "DeleteByStatus.h" 30 31 #include "GetByStatus.h" 31 32 #include "InByIdStatus.h" 32 33 #include "PutByIdStatus.h" 34 #include "SetPrivateBrandStatus.h" 33 35 34 36 namespace JSC { … … 50 52 InByIdStatus* addInByIdStatus(const CodeOrigin&, const InByIdStatus&); 51 53 DeleteByStatus* addDeleteByStatus(const CodeOrigin&, const DeleteByStatus&); 54 CheckPrivateBrandStatus* addCheckPrivateBrandStatus(const CodeOrigin&, const CheckPrivateBrandStatus&); 55 SetPrivateBrandStatus* addSetPrivateBrandStatus(const CodeOrigin&, const SetPrivateBrandStatus&); 52 56 53 57 void visitAggregate(SlotVisitor&); … … 67 71 func(ins); 68 72 func(deletes); 73 func(checkPrivateBrands); 74 func(setPrivateBrands); 69 75 } 70 76 … … 74 80 Vector<std::pair<CodeOrigin, std::unique_ptr<InByIdStatus>>> ins; 75 81 Vector<std::pair<CodeOrigin, std::unique_ptr<DeleteByStatus>>> deletes; 82 Vector<std::pair<CodeOrigin, std::unique_ptr<CheckPrivateBrandStatus>>> checkPrivateBrands; 83 Vector<std::pair<CodeOrigin, std::unique_ptr<SetPrivateBrandStatus>>> setPrivateBrands; 76 84 }; 77 85 -
trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.cpp
r266359 r272580 285 285 resetDelBy(codeBlock, *this, DelByKind::NormalByVal); 286 286 break; 287 case AccessType::CheckPrivateBrand: 288 resetCheckPrivateBrand(codeBlock, *this); 289 break; 290 case AccessType::SetPrivateBrand: 291 resetSetPrivateBrand(codeBlock, *this); 292 break; 287 293 } 288 294 -
trunk/Source/JavaScriptCore/bytecode/StructureStubInfo.h
r268794 r272580 60 60 DeleteByVal, 61 61 GetPrivateName, 62 CheckPrivateBrand, 63 SetPrivateBrand, 62 64 }; 63 65 … … 353 355 GPRReg prototypeGPR; 354 356 GPRReg propertyGPR; 357 GPRReg brandGPR; 355 358 } regs; 356 359 #if USE(JSVALUE32_64) … … 362 365 GPRReg thisTagGPR; 363 366 GPRReg propertyTagGPR; 367 GPRReg brandTagGPR; 364 368 } v; 365 369 #endif -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r261895 r272580 70 70 m_rareData->m_needsClassFieldInitializer = static_cast<unsigned>(NeedsClassFieldInitializer::Yes); 71 71 } 72 if (info.privateBrandRequirement() == PrivateBrandRequirement::Needed) { 73 createRareDataIfNecessary(holdLock(cellLock())); 74 m_rareData->m_privateBrandRequirement = static_cast<unsigned>(PrivateBrandRequirement::Needed); 75 } 72 76 } 73 77 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r259676 r272580 267 267 } 268 268 269 PrivateBrandRequirement privateBrandRequirement() const 270 { 271 if (m_rareData) 272 return static_cast<PrivateBrandRequirement>(m_rareData->m_privateBrandRequirement); 273 return PrivateBrandRequirement::None; 274 } 275 269 276 void dump(PrintStream&) const; 270 277 … … 408 415 409 416 unsigned m_needsClassFieldInitializer : 1; 417 unsigned m_privateBrandRequirement : 1; 410 418 }; 411 419 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h
r259676 r272580 51 51 JSParserScriptMode scriptMode() const { return m_codeBlock->scriptMode(); } 52 52 NeedsClassFieldInitializer needsClassFieldInitializer() const { return m_codeBlock->needsClassFieldInitializer(); } 53 PrivateBrandRequirement privateBrandRequirement() const { return m_codeBlock->privateBrandRequirement(); } 53 54 bool usesEval() const { return m_codeBlock->usesEval(); } 54 55 SourceParseMode parseMode() const { return m_codeBlock->parseMode(); } -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
r271420 r272580 71 71 bool isClassContext = executable->superBinding() == SuperBinding::Needed || executable->parseMode() == SourceParseMode::ClassFieldInitializerMode; 72 72 73 UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(vm, FunctionCode, ExecutableInfo(function->usesEval(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), scriptMode, executable->superBinding(), parseMode, executable->derivedContextType(), executable->needsClassFieldInitializer(), false, isClassContext, EvalContextType::FunctionEvalContext), codeGenerationMode);73 UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(vm, FunctionCode, ExecutableInfo(function->usesEval(), kind == CodeForConstruct, executable->privateBrandRequirement(), functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), scriptMode, executable->superBinding(), parseMode, executable->derivedContextType(), executable->needsClassFieldInitializer(), false, isClassContext, EvalContextType::FunctionEvalContext), codeGenerationMode); 74 74 75 75 auto parentScopeTDZVariables = executable->parentScopeTDZVariables(); 76 PrivateNameEnvironment parentPrivateNameEnvironment = executable->parentPrivateNameEnvironment(); 76 77 ECMAMode ecmaMode = executable->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy(); 77 error = BytecodeGenerator::generate(vm, function.get(), source, result, codeGenerationMode, parentScopeTDZVariables, ecmaMode);78 error = BytecodeGenerator::generate(vm, function.get(), source, result, codeGenerationMode, parentScopeTDZVariables, &parentPrivateNameEnvironment, ecmaMode); 78 79 79 80 if (error.isValid()) … … 83 84 } 84 85 85 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM& vm, Structure* structure, const SourceCode& parentSource, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, RefPtr<TDZEnvironmentLink> parentScopeTDZVariables, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isBuiltinDefaultClassConstructor)86 UnlinkedFunctionExecutable::UnlinkedFunctionExecutable(VM& vm, Structure* structure, const SourceCode& parentSource, FunctionMetadataNode* node, UnlinkedFunctionKind kind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, RefPtr<TDZEnvironmentLink> parentScopeTDZVariables, Optional<PrivateNameEnvironment> parentPrivateNameEnvironment, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement, bool isBuiltinDefaultClassConstructor) 86 87 : Base(vm, structure) 87 88 , m_firstLineOffset(node->firstLine() - parentSource.firstLine().oneBasedInt()) … … 104 105 , m_typeProfilingEndOffset(node->startStartOffset() + node->source().length() - 1) 105 106 , m_parameterCount(node->parameterCount()) 107 , m_privateBrandRequirement(static_cast<unsigned>(privateBrandRequirement)) 106 108 , m_features(0) 107 109 , m_sourceParseMode(node->parseMode()) … … 123 125 ASSERT(m_superBinding == static_cast<unsigned>(node->superBinding())); 124 126 ASSERT(m_derivedContextType == static_cast<unsigned>(derivedContextType)); 127 ASSERT(m_privateBrandRequirement == static_cast<unsigned>(privateBrandRequirement)); 125 128 ASSERT(!(m_isBuiltinDefaultClassConstructor && constructorKind() == ConstructorKind::None)); 126 129 ASSERT(!m_needsClassFieldInitializer || (isClassConstructorFunction() || derivedContextType == DerivedContextType::DerivedConstructorContext)); … … 129 132 if (parentScopeTDZVariables) 130 133 ensureRareData().m_parentScopeTDZVariables = WTFMove(parentScopeTDZVariables); 134 if (parentPrivateNameEnvironment) 135 ensureRareData().m_parentPrivateNameEnvironment = WTFMove(*parentPrivateNameEnvironment); 131 136 } 132 137 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
r270870 r272580 71 71 } 72 72 73 static UnlinkedFunctionExecutable* create(VM& vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, RefPtr<TDZEnvironmentLink> parentScopeTDZVariables, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isBuiltinDefaultClassConstructor = false)73 static UnlinkedFunctionExecutable* create(VM& vm, const SourceCode& source, FunctionMetadataNode* node, UnlinkedFunctionKind unlinkedFunctionKind, ConstructAbility constructAbility, JSParserScriptMode scriptMode, RefPtr<TDZEnvironmentLink> parentScopeTDZVariables, Optional<PrivateNameEnvironment> parentPrivateNameEnvironment, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement, bool isBuiltinDefaultClassConstructor = false) 74 74 { 75 75 UnlinkedFunctionExecutable* instance = new (NotNull, allocateCell<UnlinkedFunctionExecutable>(vm.heap)) 76 UnlinkedFunctionExecutable(vm, vm.unlinkedFunctionExecutableStructure.get(), source, node, unlinkedFunctionKind, constructAbility, scriptMode, WTFMove(parentScopeTDZVariables), derivedContextType, needsClassFieldInitializer, isBuiltinDefaultClassConstructor);76 UnlinkedFunctionExecutable(vm, vm.unlinkedFunctionExecutableStructure.get(), source, node, unlinkedFunctionKind, constructAbility, scriptMode, WTFMove(parentScopeTDZVariables), WTFMove(parentPrivateNameEnvironment), derivedContextType, needsClassFieldInitializer, privateBrandRequirement, isBuiltinDefaultClassConstructor); 77 77 instance->finishCreation(vm); 78 78 return instance; … … 144 144 bool hasCapturedVariables() const { return m_hasCapturedVariables; } 145 145 146 PrivateBrandRequirement privateBrandRequirement() const { return static_cast<PrivateBrandRequirement>(m_privateBrandRequirement); } 147 146 148 static constexpr bool needsDestruction = true; 147 149 static void destroy(JSCell*); … … 175 177 return m_rareData->m_parentScopeTDZVariables; 176 178 } 179 180 PrivateNameEnvironment parentPrivateNameEnvironment() const 181 { 182 if (!m_rareData) 183 return PrivateNameEnvironment(); 184 return m_rareData->m_parentPrivateNameEnvironment; 185 } 177 186 178 187 bool isArrowFunction() const { return isArrowFunctionParseMode(parseMode()); } … … 211 220 RefPtr<TDZEnvironmentLink> m_parentScopeTDZVariables; 212 221 Vector<JSTextPosition> m_classFieldLocations; 222 PrivateNameEnvironment m_parentPrivateNameEnvironment; 213 223 }; 214 224 … … 230 240 231 241 private: 232 UnlinkedFunctionExecutable(VM&, Structure*, const SourceCode&, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, RefPtr<TDZEnvironmentLink>, JSC::DerivedContextType, JSC::NeedsClassFieldInitializer, bool isBuiltinDefaultClassConstructor);242 UnlinkedFunctionExecutable(VM&, Structure*, const SourceCode&, FunctionMetadataNode*, UnlinkedFunctionKind, ConstructAbility, JSParserScriptMode, RefPtr<TDZEnvironmentLink>, Optional<PrivateNameEnvironment>, JSC::DerivedContextType, JSC::NeedsClassFieldInitializer, PrivateBrandRequirement, bool isBuiltinDefaultClassConstructor); 233 243 UnlinkedFunctionExecutable(Decoder&, const CachedFunctionExecutable&); 234 244 … … 262 272 unsigned m_typeProfilingStartOffset; 263 273 unsigned m_typeProfilingEndOffset; 264 unsigned m_parameterCount; 274 unsigned m_parameterCount : 31; 275 unsigned m_privateBrandRequirement : 1; 265 276 CodeFeatures m_features; 266 277 SourceParseMode m_sourceParseMode; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r270874 r272580 290 290 } 291 291 292 BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, ECMAMode ecmaMode)292 BytecodeGenerator::BytecodeGenerator(VM& vm, ProgramNode* programNode, UnlinkedProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment*, ECMAMode ecmaMode) 293 293 : BytecodeGeneratorBase(makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters()) 294 294 , m_codeGenerationMode(codeGenerationMode) … … 337 337 } 338 338 339 BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionNode* functionNode, UnlinkedFunctionCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, ECMAMode ecmaMode)339 BytecodeGenerator::BytecodeGenerator(VM& vm, FunctionNode* functionNode, UnlinkedFunctionCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment* parentPrivateNameEnvironment, ECMAMode ecmaMode) 340 340 : BytecodeGeneratorBase(makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters()) 341 341 , m_codeGenerationMode(codeGenerationMode) … … 360 360 , m_derivedContextType(codeBlock->derivedContextType()) 361 361 { 362 pushPrivateAccessNames(parentPrivateNameEnvironment); 363 362 364 SymbolTable* functionSymbolTable = SymbolTable::create(m_vm); 363 365 functionSymbolTable->setUsesNonStrictEval(m_usesNonStrictEval); … … 708 710 case ConstructorKind::Base: 709 711 emitCreateThis(&m_thisRegister); 712 if (Options::usePrivateMethods() && privateBrandRequirement() == PrivateBrandRequirement::Needed) 713 emitInstallPrivateBrand(&m_thisRegister); 714 710 715 emitInstanceFieldInitializationIfNeeded(&m_thisRegister, &m_calleeRegister, m_scopeNode->position(), m_scopeNode->position(), m_scopeNode->position()); 711 716 break; … … 839 844 } 840 845 841 BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, ECMAMode ecmaMode)846 BytecodeGenerator::BytecodeGenerator(VM& vm, EvalNode* evalNode, UnlinkedEvalCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment* parentPrivateNameEnvironment, ECMAMode ecmaMode) 842 847 : BytecodeGeneratorBase(makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters()) 843 848 , m_codeGenerationMode(codeGenerationMode) … … 857 862 m_codeBlock->setNumParameters(1); 858 863 864 pushPrivateAccessNames(parentPrivateNameEnvironment); 865 859 866 m_cachedParentTDZ = parentScopeTDZVariables; 860 867 … … 902 909 } 903 910 904 BytecodeGenerator::BytecodeGenerator(VM& vm, ModuleProgramNode* moduleProgramNode, UnlinkedModuleProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, ECMAMode ecmaMode)911 BytecodeGenerator::BytecodeGenerator(VM& vm, ModuleProgramNode* moduleProgramNode, UnlinkedModuleProgramCodeBlock* codeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment*, ECMAMode ecmaMode) 905 912 : BytecodeGeneratorBase(makeUnique<UnlinkedCodeBlockGenerator>(vm, codeBlock), CodeBlock::llintBaselineCalleeSaveSpaceAsVirtualRegisters()) 906 913 , m_codeGenerationMode(codeGenerationMode) … … 1894 1901 // FIXME: only do this if there is an eval() within a nested scope --- otherwise it isn't needed. 1895 1902 // https://bugs.webkit.org/show_bug.cgi?id=206663 1896 if (entry.value.isPrivateName()) 1897 symbolTable->addPrivateName(entry.key.get()); 1903 if (entry.value.isPrivateField()) 1904 symbolTable->addPrivateName(entry.key.get(), PrivateNameEntry(PrivateNameEntry::Traits::IsDeclared)); 1905 else if (entry.value.isPrivateMethod()) 1906 symbolTable->addPrivateName(entry.key.get(), PrivateNameEntry(PrivateNameEntry::Traits::IsDeclared | PrivateNameEntry::Traits::IsMethod)); 1898 1907 } 1899 1908 } … … 2715 2724 } 2716 2725 2717 RegisterID* BytecodeGenerator::emit DirectGetByVal(RegisterID* dst, RegisterID* base, RegisterID* property)2726 RegisterID* BytecodeGenerator::emitGetPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property) 2718 2727 { 2719 2728 OpGetPrivateName::emit(this, dst, base, property); … … 2751 2760 } 2752 2761 2762 void BytecodeGenerator::emitCreatePrivateBrand(RegisterID* scope, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd) 2763 { 2764 RefPtr<RegisterID> createPrivateSymbol = moveLinkTimeConstant(nullptr, LinkTimeConstant::createPrivateSymbol); 2765 2766 CallArguments arguments(*this, nullptr, 0); 2767 emitLoad(arguments.thisRegister(), jsUndefined()); 2768 RegisterID* newSymbol = emitCall(finalDestination(nullptr, createPrivateSymbol.get()), createPrivateSymbol.get(), NoExpectedFunction, arguments, divot, divotStart, divotEnd, DebuggableCall::No); 2769 2770 Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName()); 2771 2772 emitPutToScope(scope, privateBrandVar, newSymbol, DoNotThrowIfNotFound, InitializationMode::Initialization); 2773 } 2774 2775 void BytecodeGenerator::emitInstallPrivateBrand(RegisterID* target) 2776 { 2777 Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName()); 2778 RefPtr<RegisterID> privateBrandVarScope = emitResolveScope(nullptr, privateBrandVar); 2779 RegisterID* privateBrandSymbol = emitGetPrivateBrand(newTemporary(), privateBrandVarScope.get()); 2780 OpSetPrivateBrand::emit(this, target, privateBrandSymbol); 2781 } 2782 2783 RegisterID* BytecodeGenerator::emitGetPrivateBrand(RegisterID* dst, RegisterID* scope) 2784 { 2785 Variable privateBrandVar = variable(propertyNames().builtinNames().privateBrandPrivateName()); 2786 return emitGetFromScope(dst, scope, privateBrandVar, ThrowIfNotFound); 2787 } 2788 2753 2789 RegisterID* BytecodeGenerator::emitPrivateFieldPut(RegisterID* base, RegisterID* property, RegisterID* value) 2754 2790 { 2755 2791 OpPutPrivateName::emit(this, base, property, value, PrivateFieldPutKind::set()); 2756 2792 return value; 2793 } 2794 2795 void BytecodeGenerator::emitCheckPrivateBrand(RegisterID* base, RegisterID* brandSymbol) 2796 { 2797 OpCheckPrivateBrand::emit(this, base, brandSymbol); 2757 2798 } 2758 2799 … … 2889 2930 } 2890 2931 } 2932 } 2933 2934 bool BytecodeGenerator::isPrivateMethod(const Identifier& ident) 2935 { 2936 for (unsigned i = m_privateNamesStack.size(); i--; ) { 2937 auto& map = m_privateNamesStack[i]; 2938 auto it = map.find(ident.impl()); 2939 if (it != map.end()) 2940 return it->value.isMethod(); 2941 } 2942 2943 return false; 2944 } 2945 2946 void BytecodeGenerator::pushPrivateAccessNames(const PrivateNameEnvironment* environment) 2947 { 2948 if (!environment || !environment->size()) 2949 return; 2950 2951 m_privateNamesStack.append(*environment); 2952 } 2953 2954 void BytecodeGenerator::popPrivateAccessNames() 2955 { 2956 ASSERT(m_privateNamesStack.size()); 2957 m_privateNamesStack.removeLast(); 2891 2958 } 2892 2959 … … 2910 2977 2911 2978 m_TDZStack.append(TDZStackEntry { WTFMove(map), nullptr }); 2979 } 2980 2981 Optional<PrivateNameEnvironment> BytecodeGenerator::getAvailablePrivateAccessNames() 2982 { 2983 PrivateNameEnvironment result; 2984 SmallPtrSet<UniquedStringImpl*, 16> excludedNames; 2985 for (unsigned i = m_privateNamesStack.size(); i--; ) { 2986 auto& map = m_privateNamesStack[i]; 2987 for (auto& entry : map) { 2988 if (entry.value.isPrivateMethodOrAcessor()) { 2989 if (!excludedNames.contains(entry.key.get())) { 2990 result.add(entry.key, entry.value); 2991 excludedNames.add(entry.key.get()); 2992 } 2993 } else 2994 excludedNames.add(entry.key.get()); 2995 } 2996 } 2997 2998 if (!result.size()) 2999 return WTF::nullopt; 3000 return result; 2912 3001 } 2913 3002 … … 3121 3210 3122 3211 RegisterID* BytecodeGenerator::emitNewDefaultConstructor(RegisterID* dst, ConstructorKind constructorKind, const Identifier& name, 3123 const Identifier& ecmaName, const SourceCode& classSource, NeedsClassFieldInitializer needsClassFieldInitializer )3124 { 3125 UnlinkedFunctionExecutable* executable = m_vm.builtinExecutables()->createDefaultConstructor(constructorKind, name, needsClassFieldInitializer );3212 const Identifier& ecmaName, const SourceCode& classSource, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement) 3213 { 3214 UnlinkedFunctionExecutable* executable = m_vm.builtinExecutables()->createDefaultConstructor(constructorKind, name, needsClassFieldInitializer, privateBrandRequirement); 3126 3215 executable->setInvalidTypeProfilingOffsets(); 3127 3216 executable->setEcmaName(ecmaName); … … 3147 3236 3148 3237 auto variablesUnderTDZ = getVariablesUnderTDZ(); 3238 Optional<PrivateNameEnvironment> parentPrivateNameEnvironment = getAvailablePrivateAccessNames(); 3149 3239 SourceParseMode parseMode = SourceParseMode::ClassFieldInitializerMode; 3150 3240 ConstructAbility constructAbility = ConstructAbility::CannotConstruct; … … 3153 3243 FunctionMetadataNode metadata(parserArena(), JSTokenLocation(), JSTokenLocation(), 0, 0, 0, 0, 0, alwaysStrictInClass, ConstructorKind::None, superBinding, 0, parseMode, false); 3154 3244 metadata.finishParsing(m_scopeNode->source(), Identifier(), FunctionMode::MethodDefinition); 3155 auto initializer = UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), &metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, scriptMode(), WTFMove(variablesUnderTDZ), newDerivedContextType, NeedsClassFieldInitializer::No);3245 auto initializer = UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), &metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, scriptMode(), WTFMove(variablesUnderTDZ), WTFMove(parentPrivateNameEnvironment), newDerivedContextType, NeedsClassFieldInitializer::No, PrivateBrandRequirement::None); 3156 3246 initializer->setClassFieldLocations(WTFMove(classFieldLocations)); 3157 3247 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r270874 r272580 409 409 typedef DeclarationStacks::FunctionStack FunctionStack; 410 410 411 BytecodeGenerator(VM&, ProgramNode*, UnlinkedProgramCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, ECMAMode);412 BytecodeGenerator(VM&, FunctionNode*, UnlinkedFunctionCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, ECMAMode);413 BytecodeGenerator(VM&, EvalNode*, UnlinkedEvalCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, ECMAMode);414 BytecodeGenerator(VM&, ModuleProgramNode*, UnlinkedModuleProgramCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, ECMAMode);411 BytecodeGenerator(VM&, ProgramNode*, UnlinkedProgramCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, const PrivateNameEnvironment*, ECMAMode); 412 BytecodeGenerator(VM&, FunctionNode*, UnlinkedFunctionCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, const PrivateNameEnvironment*, ECMAMode); 413 BytecodeGenerator(VM&, EvalNode*, UnlinkedEvalCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, const PrivateNameEnvironment*, ECMAMode); 414 BytecodeGenerator(VM&, ModuleProgramNode*, UnlinkedModuleProgramCodeBlock*, OptionSet<CodeGenerationMode>, const RefPtr<TDZEnvironmentLink>&, const PrivateNameEnvironment*, ECMAMode); 415 415 416 416 ~BytecodeGenerator(); … … 426 426 bool usesEval() const { return m_scopeNode->usesEval(); } 427 427 bool usesThis() const { return m_scopeNode->usesThis(); } 428 PrivateBrandRequirement privateBrandRequirement() const { return m_codeBlock->privateBrandRequirement(); } 428 429 ConstructorKind constructorKind() const { return m_codeBlock->constructorKind(); } 429 430 SuperBinding superBinding() const { return m_codeBlock->superBinding(); } … … 432 433 433 434 template<typename Node, typename UnlinkedCodeBlock> 434 static ParserError generate(VM& vm, Node* node, const SourceCode& sourceCode, UnlinkedCodeBlock* unlinkedCodeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, ECMAMode ecmaMode)435 static ParserError generate(VM& vm, Node* node, const SourceCode& sourceCode, UnlinkedCodeBlock* unlinkedCodeBlock, OptionSet<CodeGenerationMode> codeGenerationMode, const RefPtr<TDZEnvironmentLink>& parentScopeTDZVariables, const PrivateNameEnvironment* privateNameEnvironment, ECMAMode ecmaMode) 435 436 { 436 437 MonotonicTime before; … … 439 440 440 441 DeferGC deferGC(vm.heap); 441 auto bytecodeGenerator = makeUnique<BytecodeGenerator>(vm, node, unlinkedCodeBlock, codeGenerationMode, parentScopeTDZVariables, ecmaMode);442 auto bytecodeGenerator = makeUnique<BytecodeGenerator>(vm, node, unlinkedCodeBlock, codeGenerationMode, parentScopeTDZVariables, privateNameEnvironment, ecmaMode); 442 443 auto result = bytecodeGenerator->generate(); 443 444 … … 775 776 RegisterID* emitNewFunction(RegisterID* dst, FunctionMetadataNode*); 776 777 RegisterID* emitNewFunctionExpression(RegisterID* dst, FuncExprNode*); 777 RegisterID* emitNewDefaultConstructor(RegisterID* dst, ConstructorKind, const Identifier& name, const Identifier& ecmaName, const SourceCode& classSource, NeedsClassFieldInitializer );778 RegisterID* emitNewDefaultConstructor(RegisterID* dst, ConstructorKind, const Identifier& name, const Identifier& ecmaName, const SourceCode& classSource, NeedsClassFieldInitializer, PrivateBrandRequirement); 778 779 RegisterID* emitNewClassFieldInitializerFunction(RegisterID* dst, Vector<JSTextPosition>&& classFieldLocations, bool isDerived); 779 780 RegisterID* emitNewArrowFunctionExpression(RegisterID*, ArrowFuncExprNode*); … … 816 817 RegisterID* emitPutByVal(RegisterID* base, RegisterID* property, RegisterID* value); 817 818 RegisterID* emitPutByVal(RegisterID* base, RegisterID* thisValue, RegisterID* property, RegisterID* value); 818 RegisterID* emitDirectGetByVal(RegisterID* dst, RegisterID* base, RegisterID* property);819 819 RegisterID* emitDirectPutByVal(RegisterID* base, RegisterID* property, RegisterID* value); 820 820 RegisterID* emitDeleteByVal(RegisterID* dst, RegisterID* base, RegisterID* property); … … 824 824 RegisterID* emitDefinePrivateField(RegisterID* base, RegisterID* property, RegisterID* value); 825 825 RegisterID* emitPrivateFieldPut(RegisterID* base, RegisterID* property, RegisterID* value); 826 RegisterID* emitGetPrivateName(RegisterID* dst, RegisterID* base, RegisterID* property); 827 828 void emitCreatePrivateBrand(RegisterID* dst, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd); 829 void emitInstallPrivateBrand(RegisterID* target); 830 RegisterID* emitGetPrivateBrand(RegisterID* dst, RegisterID* scope); 831 void emitCheckPrivateBrand(RegisterID* base, RegisterID* brand); 826 832 827 833 void emitSuperSamplerBegin(); … … 1177 1183 1178 1184 NeedsClassFieldInitializer needsClassFieldInitializer = metadata->isConstructorAndNeedsClassFieldInitializer() ? NeedsClassFieldInitializer::Yes : NeedsClassFieldInitializer::No; 1185 PrivateBrandRequirement privateBrandRequirement = metadata->privateBrandRequirement(); 1179 1186 if (SourceParseModeSet(SourceParseMode::ArrowFunctionMode, SourceParseMode::AsyncArrowFunctionMode, SourceParseMode::AsyncArrowFunctionBodyMode).contains(metadata->parseMode())) { 1180 1187 if (constructorKind() == ConstructorKind::Extends || isDerivedConstructorContext()) { 1181 1188 newDerivedContextType = DerivedContextType::DerivedConstructorContext; 1182 1189 needsClassFieldInitializer = m_codeBlock->needsClassFieldInitializer(); 1190 privateBrandRequirement = m_codeBlock->privateBrandRequirement(); 1183 1191 } 1184 1192 else if (m_codeBlock->isClassContext() || isDerivedClassContext()) … … 1187 1195 1188 1196 auto optionalVariablesUnderTDZ = getVariablesUnderTDZ(); 1197 Optional<PrivateNameEnvironment> parentPrivateNameEnvironment = getAvailablePrivateAccessNames(); 1189 1198 1190 1199 // FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized. … … 1195 1204 constructAbility = ConstructAbility::CanConstruct; 1196 1205 1197 return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, scriptMode(), WTFMove(optionalVariablesUnderTDZ), newDerivedContextType, needsClassFieldInitializer);1206 return UnlinkedFunctionExecutable::create(m_vm, m_scopeNode->source(), metadata, isBuiltinFunction() ? UnlinkedBuiltinFunction : UnlinkedNormalFunction, constructAbility, scriptMode(), WTFMove(optionalVariablesUnderTDZ), WTFMove(parentPrivateNameEnvironment), newDerivedContextType, needsClassFieldInitializer, privateBrandRequirement); 1198 1207 } 1199 1208 1200 1209 RefPtr<TDZEnvironmentLink> getVariablesUnderTDZ(); 1210 Optional<PrivateNameEnvironment> getAvailablePrivateAccessNames(); 1201 1211 1202 1212 RegisterID* emitConstructVarargs(RegisterID* dst, RegisterID* func, RegisterID* thisRegister, RegisterID* arguments, RegisterID* firstFreeRegister, int32_t firstVarArgOffset, const JSTextPosition& divot, const JSTextPosition& divotStart, const JSTextPosition& divotEnd, DebuggableCall); … … 1254 1264 } 1255 1265 1266 bool isPrivateMethod(const Identifier&); 1267 1268 void pushPrivateAccessNames(const PrivateNameEnvironment*); 1269 void popPrivateAccessNames(); 1270 1256 1271 private: 1257 1272 OptionSet<CodeGenerationMode> m_codeGenerationMode; … … 1267 1282 RefPtr<TDZEnvironmentLink> m_cachedParentTDZ; 1268 1283 Vector<TDZStackEntry> m_TDZStack; 1284 Vector<PrivateNameEnvironment> m_privateNamesStack; 1269 1285 Optional<size_t> m_varScopeLexicalScopeStackIndex; 1270 1286 void pushTDZVariables(const VariableEnvironment&, TDZCheckOptimization, TDZRequirement); -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r272243 r272580 564 564 for (PropertyListNode* p = this; p; p = p->m_next) { 565 565 const PropertyNode& node = *p->m_node; 566 if (node.type() & PropertyNode::Private ) {566 if (node.type() & PropertyNode::PrivateField) { 567 567 if (!createPrivateSymbol) 568 568 createPrivateSymbol = generator.moveLinkTimeConstant(nullptr, LinkTimeConstant::createPrivateSymbol); … … 590 590 emitSaveComputedFieldName(generator, *p->m_node); 591 591 592 if (p->isInstanceClassField() ) {592 if (p->isInstanceClassField() && !(p->m_node->type() & PropertyNode::PrivateMethod)) { 593 593 ASSERT(instanceFieldLocations); 594 594 instanceFieldLocations->append(p->position()); … … 758 758 { 759 759 // Private fields are handled in a synthetic classFieldInitializer function, not here. 760 ASSERT(!(node.type() & PropertyNode::Private ));760 ASSERT(!(node.type() & PropertyNode::PrivateField)); 761 761 762 762 if (PropertyNode::isUnderscoreProtoSetter(generator.vm(), node)) { … … 783 783 if (node.isClassProperty()) { 784 784 ASSERT(node.needsSuperBinding()); 785 786 if (node.type() & PropertyNode::PrivateMethod) { 787 Variable var = generator.variable(*node.name()); 788 generator.emitPutToScope(generator.scopeRegister(), var, value.get(), DoNotThrowIfNotFound, InitializationMode::ConstInitialization); 789 return; 790 } 791 792 RefPtr<RegisterID> propertyNameRegister; 785 793 if (node.name()) 786 794 propertyName = generator.emitLoad(nullptr, *node.name()); … … 911 919 RegisterID* BaseDotNode::emitGetPropertyValue(BytecodeGenerator& generator, RegisterID* dst, RegisterID* base, RefPtr<RegisterID>& thisValue) 912 920 { 913 if (isPrivateField()) { 921 if (isPrivateMember()) { 922 if (generator.isPrivateMethod(identifier())) { 923 Variable var = generator.variable(identifier()); 924 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 925 926 RegisterID* privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get()); 927 generator.emitCheckPrivateBrand(base, privateBrandSymbol); 928 929 return generator.emitGetFromScope(dst, scope.get(), var, ThrowIfNotFound); 930 } 931 914 932 Variable var = generator.variable(m_ident); 915 933 ASSERT_WITH_MESSAGE(!var.local(), "Private Field names must be stored in captured variables"); … … 918 936 RefPtr<RegisterID> privateName = generator.newTemporary(); 919 937 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); 920 return generator.emit DirectGetByVal(dst, base, privateName.get());938 return generator.emitGetPrivateName(dst, base, privateName.get()); 921 939 } 922 940 … … 938 956 RegisterID* BaseDotNode::emitPutProperty(BytecodeGenerator& generator, RegisterID* base, RegisterID* value, RefPtr<RegisterID>& thisValue) 939 957 { 940 if (isPrivateField()) { 958 if (isPrivateMember()) { 959 auto identifierName = identifier(); 960 if (generator.isPrivateMethod(identifierName)) { 961 Variable var = generator.variable(identifierName); 962 RefPtr<RegisterID> scope = generator.emitResolveScope(nullptr, var); 963 964 RegisterID* privateBrandSymbol = generator.emitGetPrivateBrand(generator.newTemporary(), scope.get()); 965 generator.emitCheckPrivateBrand(base, privateBrandSymbol); 966 967 generator.emitThrowTypeError("Trying to access a not defined private setter"); 968 } 969 941 970 Variable var = generator.variable(m_ident); 942 971 ASSERT_WITH_MESSAGE(!var.local(), "Private Field names must be stored in captured variables"); … … 1096 1125 1097 1126 // Initialize instance fields after super-call. 1127 if (Options::usePrivateMethods() && generator.privateBrandRequirement() == PrivateBrandRequirement::Needed) 1128 generator.emitInstallPrivateBrand(generator.thisRegister()); 1129 1098 1130 if (generator.needsClassFieldInitializer() == NeedsClassFieldInitializer::Yes) { 1099 1131 ASSERT(generator.isConstructor() || generator.isDerivedConstructorContext()); … … 1101 1133 generator.emitInstanceFieldInitializationIfNeeded(generator.thisRegister(), func.get(), divot(), divotStart(), divotEnd()); 1102 1134 } 1103 1104 1135 return ret; 1105 1136 } … … 2255 2286 generator.emitExpressionInfo(dotAccessor->divot(), dotAccessor->divotStart(), dotAccessor->divotEnd()); 2256 2287 2257 if (dotAccessor->isPrivate Field()) {2288 if (dotAccessor->isPrivateMember()) { 2258 2289 ASSERT(!baseIsSuper); 2259 2290 Variable var = generator.variable(ident); … … 2262 2293 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); 2263 2294 2264 RefPtr<RegisterID> value = generator.emit DirectGetByVal(generator.newTemporary(), base.get(), privateName.get());2295 RefPtr<RegisterID> value = generator.emitGetPrivateName(generator.newTemporary(), base.get(), privateName.get()); 2265 2296 RefPtr<RegisterID> oldValue = emitPostIncOrDec(generator, generator.tempDestination(dst), value.get(), m_operator); 2266 2297 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); … … 2494 2525 generator.emitExpressionInfo(dotAccessor->divot(), dotAccessor->divotStart(), dotAccessor->divotEnd()); 2495 2526 RegisterID* value; 2496 if (dotAccessor->isPrivate Field()) {2527 if (dotAccessor->isPrivateMember()) { 2497 2528 ASSERT(!baseNode->isSuperNode()); 2498 2529 Variable var = generator.variable(ident); … … 2501 2532 generator.emitGetFromScope(privateName.get(), scope.get(), var, DoNotThrowIfNotFound); 2502 2533 2503 value = generator.emit DirectGetByVal(propDst.get(), base.get(), privateName.get());2534 value = generator.emitGetPrivateName(propDst.get(), base.get(), privateName.get()); 2504 2535 emitIncOrDec(generator, value, m_operator); 2505 2536 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); … … 4916 4947 generator.pushLexicalScope(this, BytecodeGenerator::TDZCheckOptimization::Optimize, BytecodeGenerator::NestedScopeType::IsNested); 4917 4948 4949 bool hasPrivateNames = !!m_lexicalVariables.privateNamesSize(); 4950 bool shouldEmitPrivateBrand = m_lexicalVariables.hasPrivateMethodOrAccessor(); 4951 if (hasPrivateNames) 4952 generator.pushPrivateAccessNames(m_lexicalVariables.privateNameEnvironment()); 4953 if (shouldEmitPrivateBrand) 4954 generator.emitCreatePrivateBrand(generator.scopeRegister(), m_position, m_position, m_position); 4955 4918 4956 RefPtr<RegisterID> superclass; 4919 4957 if (m_classHeritage) { … … 4926 4964 4927 4965 auto needsClassFieldInitializer = this->hasInstanceFields() ? NeedsClassFieldInitializer::Yes : NeedsClassFieldInitializer::No; 4928 4966 auto privateBrandRequirement = shouldEmitPrivateBrand ? PrivateBrandRequirement::Needed : PrivateBrandRequirement::None; 4929 4967 if (m_constructorExpression) { 4930 4968 ASSERT(m_constructorExpression->isFuncExprNode()); … … 4933 4971 metadata->setClassSource(m_classSource); 4934 4972 metadata->setNeedsClassFieldInitializer(needsClassFieldInitializer == NeedsClassFieldInitializer::Yes); 4973 metadata->setPrivateBrandRequirement(privateBrandRequirement); 4935 4974 constructor = generator.emitNode(constructor.get(), m_constructorExpression); 4936 4975 needsHomeObject = m_classHeritage || metadata->superBinding() == SuperBinding::Needed; 4937 4976 } else 4938 constructor = generator.emitNewDefaultConstructor(constructor.get(), m_classHeritage ? ConstructorKind::Extends : ConstructorKind::Base, m_name, ecmaName(), m_classSource, needsClassFieldInitializer );4977 constructor = generator.emitNewDefaultConstructor(constructor.get(), m_classHeritage ? ConstructorKind::Extends : ConstructorKind::Base, m_name, ecmaName(), m_classSource, needsClassFieldInitializer, privateBrandRequirement); 4939 4978 4940 4979 const auto& propertyNames = generator.propertyNames(); … … 5014 5053 if (m_needsLexicalScope) 5015 5054 generator.popLexicalScope(this); 5055 5056 if (hasPrivateNames) 5057 generator.popPrivateAccessNames(); 5016 5058 5017 5059 return generator.move(generator.finalDestination(dst, constructor.get()), constructor.get()); -
trunk/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
r269115 r272580 260 260 261 261 TDZEnvironment variablesUnderTDZ; 262 VariableEnvironment privateNames;263 JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ, privateName s);262 PrivateNameEnvironment privateNameEnvironment; 263 JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ, privateNameEnvironment); 264 264 265 265 ECMAMode ecmaMode = codeBlock->ownerExecutable()->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy(); 266 auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()-> isArrowFunction(), codeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNames, ecmaMode);266 auto* eval = DirectEvalExecutable::create(globalObject, makeSource(script, callFrame->callerSourceOrigin(vm)), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->needsClassFieldInitializer(), codeBlock->unlinkedCodeBlock()->privateBrandRequirement(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), codeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNameEnvironment, ecmaMode); 267 267 if (UNLIKELY(catchScope.exception())) { 268 268 exception = catchScope.exception(); -
trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h
r272405 r272580 31 31 #include "ArrayPrototype.h" 32 32 #include "CacheableIdentifierInlines.h" 33 #include "CheckPrivateBrandStatus.h" 33 34 #include "DFGAbstractInterpreter.h" 34 35 #include "DFGAbstractInterpreterClobberState.h" … … 48 49 #include "NumberConstructor.h" 49 50 #include "PutByIdStatus.h" 51 #include "SetPrivateBrandStatus.h" 50 52 #include "StringObject.h" 51 53 #include "StructureCache.h" … … 4080 4082 } 4081 4083 4084 case CheckPrivateBrand: 4085 case SetPrivateBrand: 4082 4086 case PutPrivateName: { 4083 4087 clobberWorld(); … … 4410 4414 case FilterInByIdStatus: 4411 4415 case FilterDeleteByStatus: 4416 case FilterCheckPrivateBrandStatus: 4417 case FilterSetPrivateBrandStatus: 4412 4418 case ClearCatchLocals: 4413 4419 break; … … 4597 4603 break; 4598 4604 } 4605 4606 case FilterCheckPrivateBrandStatus: { 4607 AbstractValue& value = forNode(node->child1()); 4608 if (value.m_structure.isFinite()) 4609 node->checkPrivateBrandStatus()->filter(value.m_structure.toStructureSet()); 4610 break; 4611 } 4612 4613 case FilterSetPrivateBrandStatus: { 4614 AbstractValue& value = forNode(node->child1()); 4615 if (value.m_structure.isFinite()) 4616 node->setPrivateBrandStatus()->filter(value.m_structure.toStructureSet()); 4617 break; 4618 } 4619 4599 4620 4600 4621 default: -
trunk/Source/JavaScriptCore/dfg/DFGArgumentsEliminationPhase.cpp
r264488 r272580 407 407 case FilterInByIdStatus: 408 408 case FilterDeleteByStatus: 409 case FilterCheckPrivateBrandStatus: 410 case FilterSetPrivateBrandStatus: 409 411 break; 410 412 … … 1267 1269 case FilterCallLinkStatus: 1268 1270 case FilterInByIdStatus: 1269 case FilterDeleteByStatus: { 1271 case FilterDeleteByStatus: 1272 case FilterCheckPrivateBrandStatus: 1273 case FilterSetPrivateBrandStatus: { 1270 1274 if (!isEliminatedAllocation(node->child1().node())) 1271 1275 break; -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r272349 r272580 38 38 #include "CacheableIdentifierInlines.h" 39 39 #include "CallLinkStatus.h" 40 #include "CheckPrivateBrandStatus.h" 40 41 #include "CodeBlock.h" 41 42 #include "CodeBlockWithJITType.h" … … 75 76 #include "PutByIdStatus.h" 76 77 #include "RegExpPrototype.h" 78 #include "SetPrivateBrandStatus.h" 77 79 #include "StackAlignment.h" 78 80 #include "StringConstructor.h" … … 6260 6262 6261 6263 NEXT_OPCODE(op_put_by_val_with_this); 6264 } 6265 6266 case op_check_private_brand: { 6267 auto bytecode = currentInstruction->as<OpCheckPrivateBrand>(); 6268 Node* base = get(bytecode.m_base); 6269 Node* brand = get(bytecode.m_brand); 6270 bool compiledAsCheckStructure = false; 6271 6272 CheckPrivateBrandStatus checkStatus = CheckPrivateBrandStatus::computeFor( 6273 m_inlineStackTop->m_profiledBlock, 6274 m_inlineStackTop->m_baselineMap, m_icContextStack, 6275 currentCodeOrigin()); 6276 6277 if (!m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadIdent) 6278 && !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadType) 6279 && !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadConstantValue)) { 6280 6281 if (CacheableIdentifier identifier = checkStatus.singleIdentifier()) { 6282 m_graph.identifiers().ensure(identifier.uid()); 6283 ASSERT(identifier.isSymbol()); 6284 FrozenValue* frozen = m_graph.freezeStrong(identifier.cell()); 6285 addToGraph(CheckIsConstant, OpInfo(frozen), brand); 6286 6287 if (checkStatus.isSimple() && checkStatus.variants().size() && Options::useAccessInlining()) { 6288 ASSERT(checkStatus.variants().size() == 1); // If we have single identifier, we should have only 1 variant. 6289 CheckPrivateBrandVariant variant = checkStatus.variants()[0]; 6290 6291 addToGraph(FilterCheckPrivateBrandStatus, OpInfo(m_graph.m_plan.recordedStatuses().addCheckPrivateBrandStatus(currentCodeOrigin(), checkStatus)), base); 6292 addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(variant.structureSet())), base); 6293 6294 compiledAsCheckStructure = true; 6295 } 6296 } 6297 } 6298 6299 if (!compiledAsCheckStructure) 6300 addToGraph(CheckPrivateBrand, base, brand); 6301 6302 NEXT_OPCODE(op_check_private_brand); 6303 } 6304 6305 case op_set_private_brand: { 6306 auto bytecode = currentInstruction->as<OpSetPrivateBrand>(); 6307 Node* base = get(bytecode.m_base); 6308 Node* brand = get(bytecode.m_brand); 6309 6310 bool inlinedSetPrivateBrand = false; 6311 SetPrivateBrandStatus setStatus = SetPrivateBrandStatus::computeFor( 6312 m_inlineStackTop->m_profiledBlock, 6313 m_inlineStackTop->m_baselineMap, m_icContextStack, 6314 currentCodeOrigin()); 6315 6316 if (!m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadIdent) 6317 && !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadType) 6318 && !m_inlineStackTop->m_exitProfile.hasExitSite(m_currentIndex, BadConstantValue)) { 6319 6320 if (CacheableIdentifier identifier = setStatus.singleIdentifier()) { 6321 ASSERT(identifier.isSymbol()); 6322 FrozenValue* frozen = m_graph.freezeStrong(identifier.cell()); 6323 addToGraph(CheckIsConstant, OpInfo(frozen), brand); 6324 6325 6326 // FIXME: We should include a MultiSetPrivateBrand to handle polymorphic cases 6327 // https://bugs.webkit.org/show_bug.cgi?id=221570 6328 if (setStatus.isSimple() && setStatus.variants().size() == 1 && Options::useAccessInlining()) { 6329 SetPrivateBrandVariant variant = setStatus.variants()[0]; 6330 6331 addToGraph(FilterSetPrivateBrandStatus, OpInfo(m_graph.m_plan.recordedStatuses().addSetPrivateBrandStatus(currentCodeOrigin(), setStatus)), base); 6332 addToGraph(CheckStructure, OpInfo(m_graph.addStructureSet(variant.oldStructure())), base); 6333 ASSERT(variant.oldStructure()->transitionWatchpointSetHasBeenInvalidated()); 6334 ASSERT(variant.newStructure()); 6335 6336 Transition* transition = m_graph.m_transitions.add( 6337 m_graph.registerStructure(variant.oldStructure()), m_graph.registerStructure(variant.newStructure())); 6338 6339 addToGraph(PutStructure, OpInfo(transition), base); 6340 6341 inlinedSetPrivateBrand = true; 6342 } 6343 } 6344 } 6345 6346 if (!inlinedSetPrivateBrand) 6347 addToGraph(SetPrivateBrand, base, brand); 6348 6349 NEXT_OPCODE(op_set_private_brand); 6262 6350 } 6263 6351 -
trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp
r270874 r272580 295 295 case op_get_private_name: 296 296 case op_put_private_name: 297 case op_set_private_brand: 298 case op_check_private_brand: 297 299 return CanCompileAndInline; 298 300 -
trunk/Source/JavaScriptCore/dfg/DFGClobberize.h
r272170 r272580 506 506 case FilterInByIdStatus: 507 507 case FilterDeleteByStatus: 508 case FilterCheckPrivateBrandStatus: 509 case FilterSetPrivateBrandStatus: 508 510 write(SideState); 509 511 return; … … 678 680 case GetPrivateName: 679 681 case GetPrivateNameById: 682 // FIXME: We should have a better cloberize rule for both CheckPrivateBrand and SetPrivateBrand 683 // https://bugs.webkit.org/show_bug.cgi?id=221571 684 case CheckPrivateBrand: 685 case SetPrivateBrand: 680 686 case DefineDataProperty: 681 687 case DefineAccessorProperty: -
trunk/Source/JavaScriptCore/dfg/DFGClobbersExitState.cpp
r266095 r272580 85 85 case FilterInByIdStatus: 86 86 case FilterDeleteByStatus: 87 case FilterCheckPrivateBrandStatus: 88 case FilterSetPrivateBrandStatus: 87 89 case TryGetById: 88 90 // These do clobber memory, but nothing that is observable. It may be nice to separate the -
trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp
r270874 r272580 251 251 case FilterInByIdStatus: 252 252 case FilterDeleteByStatus: 253 case FilterCheckPrivateBrandStatus: 254 case FilterSetPrivateBrandStatus: 253 255 case DateGetInt32OrNaN: 254 256 case DateGetTime: … … 328 330 case GetPrivateName: 329 331 case GetPrivateNameById: 332 case SetPrivateBrand: 333 case CheckPrivateBrand: 330 334 case PutStack: 331 335 case PutToArguments: -
trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
r272405 r272580 1974 1974 1975 1975 1976 case SetPrivateBrand: { 1977 fixEdge<CellUse>(node->child1()); 1978 fixEdge<SymbolUse>(node->child2()); 1979 break; 1980 } 1981 1982 case CheckPrivateBrand: 1976 1983 case PutPrivateName: { 1977 1984 fixEdge<SymbolUse>(node->child2()); … … 2870 2877 case FilterInByIdStatus: 2871 2878 case FilterDeleteByStatus: 2879 case FilterCheckPrivateBrandStatus: 2880 case FilterSetPrivateBrandStatus: 2872 2881 case InvalidationPoint: 2873 2882 case CreateArgumentsButterfly: -
trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp
r268077 r272580 246 246 finalizeInlineCaches(m_inByIds, linkBuffer); 247 247 finalizeInlineCaches(m_instanceOfs, linkBuffer); 248 finalizeInlineCaches(m_privateBrandAccesses, linkBuffer); 248 249 249 250 auto linkCallThunk = FunctionPtr<NoPtrTag>(vm().getCTIStub(linkCallThunkGenerator).retaggedCode<NoPtrTag>()); -
trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.h
r271422 r272580 213 213 } 214 214 215 void addPrivateBrandAccess(const JITPrivateBrandAccessGenerator& gen, SlowPathGenerator* slowPath) 216 { 217 m_privateBrandAccesses.append(InlineCacheWrapper<JITPrivateBrandAccessGenerator>(gen, slowPath)); 218 } 219 215 220 void addJSCall(Call fastCall, Call slowCall, DataLabelPtr targetToCheck, CallLinkInfo* info) 216 221 { … … 363 368 Vector<InlineCacheWrapper<JITInByIdGenerator>, 4> m_inByIds; 364 369 Vector<InlineCacheWrapper<JITInstanceOfGenerator>, 4> m_instanceOfs; 370 Vector<InlineCacheWrapper<JITPrivateBrandAccessGenerator>, 4> m_privateBrandAccesses; 365 371 Vector<JSCallRecord, 4> m_jsCalls; 366 372 Vector<JSDirectCallRecord, 4> m_jsDirectCalls; -
trunk/Source/JavaScriptCore/dfg/DFGMayExit.cpp
r266095 r272580 109 109 case FilterInByIdStatus: 110 110 case FilterDeleteByStatus: 111 case FilterCheckPrivateBrandStatus: 112 case FilterSetPrivateBrandStatus: 111 113 break; 112 114 -
trunk/Source/JavaScriptCore/dfg/DFGNode.h
r270874 r272580 30 30 #include "B3SparseCollection.h" 31 31 #include "BasicBlockLocation.h" 32 #include "CheckPrivateBrandVariant.h" 32 33 #include "CodeBlock.h" 33 34 #include "DFGAdjacencyList.h" … … 55 56 #include "PrivateFieldPutKind.h" 56 57 #include "PutByIdVariant.h" 58 #include "SetPrivateBrandVariant.h" 57 59 #include "SpeculatedType.h" 58 60 #include "TypeLocation.h" … … 3141 3143 } 3142 3144 3145 bool hasCheckPrivateBrandStatus() 3146 { 3147 return op() == FilterCheckPrivateBrandStatus; 3148 } 3149 3150 CheckPrivateBrandStatus* checkPrivateBrandStatus() 3151 { 3152 ASSERT(hasCheckPrivateBrandStatus()); 3153 return m_opInfo.as<CheckPrivateBrandStatus*>(); 3154 } 3155 3156 bool hasSetPrivateBrandStatus() 3157 { 3158 return op() == FilterSetPrivateBrandStatus; 3159 } 3160 3161 SetPrivateBrandStatus* setPrivateBrandStatus() 3162 { 3163 ASSERT(hasSetPrivateBrandStatus()); 3164 return m_opInfo.as<SetPrivateBrandStatus*>(); 3165 } 3166 3143 3167 void dumpChildren(PrintStream& out) 3144 3168 { -
trunk/Source/JavaScriptCore/dfg/DFGNodeType.h
r270874 r272580 213 213 macro(PutPrivateName, NodeMustGenerate) \ 214 214 macro(PutPrivateNameById, NodeMustGenerate) \ 215 macro(CheckPrivateBrand, NodeMustGenerate) \ 216 macro(SetPrivateBrand, NodeMustGenerate) \ 215 217 macro(TryGetById, NodeResultJS) \ 216 218 macro(GetById, NodeResultJS | NodeMustGenerate) \ … … 545 547 macro(FilterPutByIdStatus, NodeMustGenerate) \ 546 548 macro(FilterDeleteByStatus, NodeMustGenerate) \ 549 macro(FilterCheckPrivateBrandStatus, NodeMustGenerate) \ 550 macro(FilterSetPrivateBrandStatus, NodeMustGenerate) \ 547 551 /* Data view access */ \ 548 552 macro(DataViewGetInt, NodeMustGenerate | NodeResultJS) /* The gets are must generate for now because they do bounds checks */ \ -
trunk/Source/JavaScriptCore/dfg/DFGObjectAllocationSinkingPhase.cpp
r267114 r272580 1262 1262 case FilterInByIdStatus: 1263 1263 case FilterDeleteByStatus: 1264 case FilterCheckPrivateBrandStatus: 1265 case FilterSetPrivateBrandStatus: 1264 1266 break; 1265 1267 … … 2612 2614 case FilterInByIdStatus: 2613 2615 case FilterDeleteByStatus: 2616 case FilterCheckPrivateBrandStatus: 2617 case FilterSetPrivateBrandStatus: 2614 2618 if (node->child1()->isPhantomAllocation()) 2615 2619 node->removeWithoutChecks(); -
trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp
r272170 r272580 1389 1389 case PutPrivateName: 1390 1390 case PutPrivateNameById: 1391 case SetPrivateBrand: 1392 case CheckPrivateBrand: 1391 1393 case PutClosureVar: 1392 1394 case PutInternalField: … … 1455 1457 case FilterInByIdStatus: 1456 1458 case FilterDeleteByStatus: 1459 case FilterCheckPrivateBrandStatus: 1460 case FilterSetPrivateBrandStatus: 1457 1461 case ClearCatchLocals: 1458 1462 case DataViewSet: -
trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h
r270874 r272580 363 363 case FilterInByIdStatus: 364 364 case FilterDeleteByStatus: 365 case FilterCheckPrivateBrandStatus: 366 case FilterSetPrivateBrandStatus: 365 367 // We don't want these to be moved anywhere other than where we put them, since we want them 366 368 // to capture "profiling" at the point in control flow here the user put them. … … 533 535 case GetPrivateName: 534 536 case GetPrivateNameById: 537 case CheckPrivateBrand: 538 case SetPrivateBrand: 535 539 case DefineDataProperty: 536 540 case DefineAccessorProperty: -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r272405 r272580 3689 3689 auto putKind = node->privateFieldPutKind().isDefine() ? PutKind::DirectPrivateFieldDefine : PutKind::DirectPrivateFieldSet; 3690 3690 cachedPutById(node->origin.semantic, baseGPR, valueRegs, scratchGPR, node->cacheableIdentifier(), putKind, ECMAMode::strict()); 3691 3692 noResult(node); 3693 } 3694 3695 void SpeculativeJIT::compileCheckPrivateBrand(Node* node) 3696 { 3697 JSValueOperand base(this, node->child1()); 3698 SpeculateCellOperand brandValue(this, node->child2()); 3699 3700 JSValueRegs baseRegs = base.jsValueRegs(); 3701 3702 GPRReg brandGPR = brandValue.gpr(); 3703 3704 speculateSymbol(node->child2(), brandGPR); 3705 3706 CodeOrigin codeOrigin = node->origin.semantic; 3707 CallSiteIndex callSite = m_jit.recordCallSiteAndGenerateExceptionHandlingOSRExitIfNeeded(codeOrigin, m_stream->size()); 3708 RegisterSet usedRegisters = this->usedRegisters(); 3709 3710 JITCompiler::JumpList slowCases; 3711 if (needsTypeCheck(node->child1(), SpecCell)) 3712 slowCases.append(m_jit.branchIfNotCell(baseRegs)); 3713 3714 JITPrivateBrandAccessGenerator gen( 3715 m_jit.codeBlock(), codeOrigin, callSite, AccessType::CheckPrivateBrand, usedRegisters, 3716 baseRegs, JSValueRegs::payloadOnly(brandGPR)); 3717 3718 gen.stubInfo()->propertyIsSymbol = true; 3719 gen.generateFastPath(m_jit); 3720 slowCases.append(gen.slowPathJump()); 3721 3722 std::unique_ptr<SlowPathGenerator> slowPath = slowPathCall( 3723 slowCases, this, operationCheckPrivateBrandOptimize, NoResult, 3724 TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(codeOrigin)), gen.stubInfo(), baseRegs, CCallHelpers::CellValue(brandGPR)); 3725 3726 m_jit.addPrivateBrandAccess(gen, slowPath.get()); 3727 addSlowPathGenerator(WTFMove(slowPath)); 3728 3729 noResult(node); 3730 } 3731 3732 void SpeculativeJIT::compileSetPrivateBrand(Node* node) 3733 { 3734 ASSERT(node->child1().useKind() == CellUse); 3735 SpeculateCellOperand base(this, node->child1()); 3736 SpeculateCellOperand brandValue(this, node->child2()); 3737 3738 GPRReg baseGPR = base.gpr(); 3739 GPRReg brandGPR = brandValue.gpr(); 3740 3741 speculateSymbol(node->child2(), brandGPR); 3742 3743 CodeOrigin codeOrigin = node->origin.semantic; 3744 CallSiteIndex callSite = m_jit.recordCallSiteAndGenerateExceptionHandlingOSRExitIfNeeded(codeOrigin, m_stream->size()); 3745 RegisterSet usedRegisters = this->usedRegisters(); 3746 3747 JITCompiler::JumpList slowCases; 3748 JITPrivateBrandAccessGenerator gen( 3749 m_jit.codeBlock(), codeOrigin, callSite, AccessType::SetPrivateBrand, usedRegisters, 3750 JSValueRegs::payloadOnly(baseGPR), JSValueRegs::payloadOnly(brandGPR)); 3751 3752 gen.stubInfo()->propertyIsSymbol = true; 3753 gen.generateFastPath(m_jit); 3754 slowCases.append(gen.slowPathJump()); 3755 3756 std::unique_ptr<SlowPathGenerator> slowPath = slowPathCall( 3757 slowCases, this, operationSetPrivateBrandOptimize, NoResult, 3758 TrustedImmPtr::weakPointer(m_graph, m_graph.globalObjectFor(codeOrigin)), gen.stubInfo(), CCallHelpers::CellValue(baseGPR), CCallHelpers::CellValue(brandGPR)); 3759 3760 m_jit.addPrivateBrandAccess(gen, slowPath.get()); 3761 addSlowPathGenerator(WTFMove(slowPath)); 3691 3762 3692 3763 noResult(node); -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
r272405 r272580 1374 1374 void compilePutPrivateName(Node*); 1375 1375 void compilePutPrivateNameById(Node*); 1376 void compileCheckPrivateBrand(Node*); 1377 void compileSetPrivateBrand(Node*); 1376 1378 void compileGetByOffset(Node*); 1377 1379 void compilePutByOffset(Node*); -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
r270874 r272580 2607 2607 } 2608 2608 2609 case CheckPrivateBrand: { 2610 compileCheckPrivateBrand(node); 2611 break; 2612 } 2613 2614 case SetPrivateBrand: { 2615 compileSetPrivateBrand(node); 2616 break; 2617 } 2618 2609 2619 case PutByValDirect: 2610 2620 case PutByVal: … … 4242 4252 case FilterInByIdStatus: 4243 4253 case FilterDeleteByStatus: 4254 case FilterCheckPrivateBrandStatus: 4255 case FilterSetPrivateBrandStatus: 4244 4256 m_interpreter.filterICStatus(node); 4245 4257 noResult(node); -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r272405 r272580 2964 2964 case PutPrivateNameById: { 2965 2965 compilePutPrivateNameById(node); 2966 break; 2967 } 2968 2969 case CheckPrivateBrand: { 2970 compileCheckPrivateBrand(node); 2971 break; 2972 } 2973 2974 case SetPrivateBrand: { 2975 compileSetPrivateBrand(node); 2966 2976 break; 2967 2977 } … … 5688 5698 case FilterInByIdStatus: 5689 5699 case FilterDeleteByStatus: 5700 case FilterCheckPrivateBrandStatus: 5701 case FilterSetPrivateBrandStatus: 5690 5702 m_interpreter.filterICStatus(node); 5691 5703 noResult(node); -
trunk/Source/JavaScriptCore/dfg/DFGStoreBarrierInsertionPhase.cpp
r267489 r272580 274 274 } 275 275 276 case SetPrivateBrand: 276 277 case PutById: 277 278 case PutByIdFlush: -
trunk/Source/JavaScriptCore/dfg/DFGVarargsForwardingPhase.cpp
r266095 r272580 200 200 case FilterInByIdStatus: 201 201 case FilterDeleteByStatus: 202 case FilterCheckPrivateBrandStatus: 203 case FilterSetPrivateBrandStatus: 202 204 break; 203 205 … … 403 405 case FilterInByIdStatus: 404 406 case FilterDeleteByStatus: 407 case FilterCheckPrivateBrandStatus: 408 case FilterSetPrivateBrandStatus: 405 409 if (node->child1().node() == candidate) 406 410 node->remove(m_graph); -
trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp
r270874 r272580 401 401 case GetPrivateName: 402 402 case GetPrivateNameById: 403 case CheckPrivateBrand: 404 case SetPrivateBrand: 403 405 case MatchStructure: 404 406 case FilterCallLinkStatus: … … 407 409 case FilterInByIdStatus: 408 410 case FilterDeleteByStatus: 411 case FilterCheckPrivateBrandStatus: 412 case FilterSetPrivateBrandStatus: 409 413 case CreateThis: 410 414 case CreatePromise: -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r272405 r272580 962 962 compileInByVal(); 963 963 break; 964 case CheckPrivateBrand: 965 compileCheckPrivateBrand(); 966 break; 967 case SetPrivateBrand: 968 compileSetPrivateBrand(); 969 break; 964 970 case HasOwnProperty: 965 971 compileHasOwnProperty(); … … 1639 1645 case FilterInByIdStatus: 1640 1646 case FilterDeleteByStatus: 1647 case FilterCheckPrivateBrandStatus: 1648 case FilterSetPrivateBrandStatus: 1641 1649 compileFilterICStatus(); 1642 1650 break; … … 4082 4090 setJSValue(m_out.phi(Int64, cellResult, notCellResult)); 4083 4091 } 4092 } 4093 4094 void compilePrivateBrandAccess(LValue base, LValue brand, AccessType accessType) 4095 { 4096 Node* node = m_node; 4097 PatchpointValue* patchpoint = m_out.patchpoint(Void); 4098 patchpoint->appendSomeRegister(base); 4099 patchpoint->appendSomeRegister(brand); 4100 patchpoint->append(m_notCellMask, ValueRep::lateReg(GPRInfo::notCellMaskRegister)); 4101 patchpoint->append(m_numberTag, ValueRep::lateReg(GPRInfo::numberTagRegister)); 4102 patchpoint->clobber(RegisterSet::macroScratchRegisters()); 4103 4104 RefPtr<PatchpointExceptionHandle> exceptionHandle = preparePatchpointForExceptions(patchpoint); 4105 4106 State* state = &m_ftlState; 4107 bool baseIsCell = abstractValue(m_node->child1()).isType(SpecCell); 4108 patchpoint->setGenerator([=] (CCallHelpers& jit, const StackmapGenerationParams& params) { 4109 AllowMacroScratchRegisterUsage allowScratch(jit); 4110 4111 CallSiteIndex callSiteIndex = state->jitCode->common.codeOrigins->addUniqueCallSiteIndex(node->origin.semantic); 4112 4113 // This is the direct exit target for operation calls. 4114 Box<CCallHelpers::JumpList> exceptions = exceptionHandle->scheduleExitCreation(params)->jumps(jit); 4115 4116 // This is the exit for call IC's created by the IC for getters. We don't have 4117 // to do anything weird other than call this, since it will associate the exit with 4118 // the callsite index. 4119 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex); 4120 4121 GPRReg baseGPR = params[0].gpr(); 4122 GPRReg brandGPR = params[1].gpr(); 4123 4124 auto generator = Box<JITPrivateBrandAccessGenerator>::create( 4125 jit.codeBlock(), node->origin.semantic, callSiteIndex, accessType, 4126 params.unavailableRegisters(), JSValueRegs(baseGPR), JSValueRegs(brandGPR)); 4127 4128 CCallHelpers::Jump notCell; 4129 if (!baseIsCell) 4130 notCell = jit.branchIfNotCell(baseGPR); 4131 4132 generator->generateFastPath(jit); 4133 CCallHelpers::Label done = jit.label(); 4134 4135 params.addLatePath([=] (CCallHelpers& jit) { 4136 AllowMacroScratchRegisterUsage allowScratch(jit); 4137 4138 auto appropriatePrivateAccessFunction = [=] (AccessType type) -> decltype(&operationCheckPrivateBrandOptimize) { 4139 switch (type) { 4140 case AccessType::CheckPrivateBrand: 4141 return operationCheckPrivateBrandOptimize; 4142 case AccessType::SetPrivateBrand: 4143 return operationSetPrivateBrandOptimize; 4144 default: 4145 RELEASE_ASSERT_NOT_REACHED(); 4146 return nullptr; 4147 } 4148 }; 4149 4150 if (notCell.isSet()) 4151 notCell.link(&jit); 4152 generator->slowPathJump().link(&jit); 4153 CCallHelpers::Label slowPathBegin = jit.label(); 4154 CCallHelpers::Call slowPathCall = callOperation( 4155 *state, params.unavailableRegisters(), jit, node->origin.semantic, 4156 exceptions.get(), appropriatePrivateAccessFunction(accessType), InvalidGPRReg, 4157 jit.codeBlock()->globalObjectFor(node->origin.semantic), 4158 CCallHelpers::TrustedImmPtr(generator->stubInfo()), baseGPR, brandGPR).call(); 4159 jit.jump().linkTo(done, &jit); 4160 4161 generator->reportSlowPathCall(slowPathBegin, slowPathCall); 4162 4163 jit.addLinkTask([=] (LinkBuffer& linkBuffer) { 4164 generator->finalize(linkBuffer, linkBuffer); 4165 }); 4166 }); 4167 }); 4168 } 4169 4170 void compileCheckPrivateBrand() 4171 { 4172 compilePrivateBrandAccess(lowJSValue(m_node->child1()), lowSymbol(m_node->child2()), AccessType::CheckPrivateBrand); 4173 } 4174 4175 void compileSetPrivateBrand() 4176 { 4177 DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == CellUse, m_node->child1().useKind()); 4178 compilePrivateBrandAccess(lowCell(m_node->child1()), lowSymbol(m_node->child2()), AccessType::SetPrivateBrand); 4084 4179 } 4085 4180 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r269922 r272580 145 145 146 146 TDZEnvironment variablesUnderTDZ; 147 VariableEnvironment privateNames;148 JSScope::collectClosureVariablesUnderTDZ(callerScopeChain, variablesUnderTDZ, privateName s);149 eval = DirectEvalExecutable::create(globalObject, makeSource(programSource, callerCodeBlock->source().provider()->sourceOrigin()), derivedContextType, callerUnlinkedCodeBlock->needsClassFieldInitializer(), isArrowFunctionContext, callerCodeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNames, ecmaMode);147 PrivateNameEnvironment privateNameEnvironment; 148 JSScope::collectClosureVariablesUnderTDZ(callerScopeChain, variablesUnderTDZ, privateNameEnvironment); 149 eval = DirectEvalExecutable::create(globalObject, makeSource(programSource, callerCodeBlock->source().provider()->sourceOrigin()), derivedContextType, callerUnlinkedCodeBlock->needsClassFieldInitializer(), callerUnlinkedCodeBlock->privateBrandRequirement(), isArrowFunctionContext, callerCodeBlock->ownerExecutable()->isInsideOrdinaryFunction(), evalContextType, &variablesUnderTDZ, &privateNameEnvironment, ecmaMode); 150 150 EXCEPTION_ASSERT(!!scope.exception() == !eval); 151 151 if (!eval) -
trunk/Source/JavaScriptCore/jit/ICStats.h
r268794 r272580 76 76 macro(OperationGetPrivateNameById) \ 77 77 macro(OperationGetPrivateNameByIdOptimize) \ 78 macro(OperationGetPrivateNameByIdGeneric) 78 macro(OperationGetPrivateNameByIdGeneric) \ 79 macro(CheckPrivateBrandAddAccessCase) \ 80 macro(SetPrivateBrandAddAccessCase) \ 81 macro(CheckPrivateBrandReplaceWithJump) \ 82 macro(SetPrivateBrandReplaceWithJump) 79 83 80 84 class ICEvent { -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r271279 r272580 359 359 DEFINE_OP(op_get_by_val) 360 360 DEFINE_OP(op_get_private_name) 361 DEFINE_OP(op_set_private_brand) 362 DEFINE_OP(op_check_private_brand) 361 363 DEFINE_OP(op_get_prototype_of) 362 364 DEFINE_OP(op_overrides_has_instance) … … 509 511 m_delByIdIndex = 0; 510 512 m_instanceOfIndex = 0; 513 m_privateBrandAccessIndex = 0; 511 514 m_byValInstructionIndex = 0; 512 515 m_callLinkInfoIndex = 0; … … 565 568 DEFINE_SLOWCASE_OP(op_get_by_val) 566 569 DEFINE_SLOWCASE_OP(op_get_private_name) 570 DEFINE_SLOWCASE_OP(op_set_private_brand) 571 DEFINE_SLOWCASE_OP(op_check_private_brand) 567 572 DEFINE_SLOWCASE_OP(op_instanceof) 568 573 DEFINE_SLOWCASE_OP(op_instanceof_custom) … … 655 660 RELEASE_ASSERT(m_inByIdIndex == m_inByIds.size()); 656 661 RELEASE_ASSERT(m_instanceOfIndex == m_instanceOfs.size()); 662 RELEASE_ASSERT(m_privateBrandAccessIndex == m_privateBrandAccesses.size()); 657 663 RELEASE_ASSERT(m_callLinkInfoIndex == m_callCompilationInfo.size()); 658 664 … … 903 909 finalizeInlineCaches(m_inByIds, patchBuffer); 904 910 finalizeInlineCaches(m_instanceOfs, patchBuffer); 911 finalizeInlineCaches(m_privateBrandAccesses, patchBuffer); 905 912 906 913 if (m_byValCompilationInfo.size()) { -
trunk/Source/JavaScriptCore/jit/JIT.h
r270874 r272580 564 564 void emit_op_get_by_val(const Instruction*); 565 565 void emit_op_get_private_name(const Instruction*); 566 void emit_op_set_private_brand(const Instruction*); 567 void emit_op_check_private_brand(const Instruction*); 566 568 void emit_op_get_argument_by_val(const Instruction*); 567 569 void emit_op_get_prototype_of(const Instruction*); … … 696 698 void emitSlow_op_get_by_val(const Instruction*, Vector<SlowCaseEntry>::iterator&); 697 699 void emitSlow_op_get_private_name(const Instruction*, Vector<SlowCaseEntry>::iterator&); 700 void emitSlow_op_set_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator&); 701 void emitSlow_op_check_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator&); 698 702 void emitSlow_op_get_argument_by_val(const Instruction*, Vector<SlowCaseEntry>::iterator&); 699 703 void emitSlow_op_in_by_id(const Instruction*, Vector<SlowCaseEntry>::iterator&); … … 986 990 Vector<JITDelByValGenerator> m_delByVals; 987 991 Vector<JITInstanceOfGenerator> m_instanceOfs; 992 Vector<JITPrivateBrandAccessGenerator> m_privateBrandAccesses; 988 993 Vector<ByValCompilationInfo> m_byValCompilationInfo; 989 994 Vector<CallCompilationInfo> m_callCompilationInfo; … … 1009 1014 unsigned m_delByIdIndex { UINT_MAX }; 1010 1015 unsigned m_instanceOfIndex { UINT_MAX }; 1016 unsigned m_privateBrandAccessIndex { UINT_MAX }; 1011 1017 unsigned m_byValInstructionIndex { UINT_MAX }; 1012 1018 unsigned m_callLinkInfoIndex { UINT_MAX }; -
trunk/Source/JavaScriptCore/jit/JITInlineCacheGenerator.cpp
r267489 r272580 325 325 } 326 326 327 JITPrivateBrandAccessGenerator::JITPrivateBrandAccessGenerator(CodeBlock* codeBlock, CodeOrigin codeOrigin, CallSiteIndex callSiteIndex, AccessType accessType, const RegisterSet& usedRegisters, JSValueRegs base, JSValueRegs brand) 328 : Base(codeBlock, codeOrigin, callSiteIndex, accessType, usedRegisters) 329 { 330 ASSERT(accessType == AccessType::CheckPrivateBrand || accessType == AccessType::SetPrivateBrand); 331 m_stubInfo->hasConstantIdentifier = false; 332 333 m_stubInfo->baseGPR = base.payloadGPR(); 334 m_stubInfo->regs.brandGPR = brand.payloadGPR(); 335 m_stubInfo->valueGPR = InvalidGPRReg; 336 #if USE(JSVALUE32_64) 337 m_stubInfo->baseTagGPR = base.tagGPR(); 338 m_stubInfo->v.brandTagGPR = brand.tagGPR(); 339 m_stubInfo->valueTagGPR = InvalidGPRReg; 340 #endif 341 } 342 343 void JITPrivateBrandAccessGenerator::generateFastPath(MacroAssembler& jit) 344 { 345 m_start = jit.label(); 346 m_slowPathJump = jit.patchableJump(); 347 m_done = jit.label(); 348 } 349 350 void JITPrivateBrandAccessGenerator::finalize( 351 LinkBuffer& fastPath, LinkBuffer& slowPath) 352 { 353 ASSERT(m_start.isSet()); 354 Base::finalize( 355 fastPath, slowPath, fastPath.locationOf<JITStubRoutinePtrTag>(m_start)); 356 } 357 327 358 } // namespace JSC 328 359 -
trunk/Source/JavaScriptCore/jit/JITInlineCacheGenerator.h
r267489 r272580 247 247 JSValueRegs m_base; 248 248 JSValueRegs m_result; 249 JSValueRegs m_; 250 249 250 MacroAssembler::Label m_start; 251 MacroAssembler::PatchableJump m_slowPathJump; 252 }; 253 254 class JITPrivateBrandAccessGenerator : public JITInlineCacheGenerator { 255 using Base = JITInlineCacheGenerator; 256 public: 257 JITPrivateBrandAccessGenerator() { } 258 259 JITPrivateBrandAccessGenerator( 260 CodeBlock*, CodeOrigin, CallSiteIndex, AccessType, const RegisterSet& usedRegisters, 261 JSValueRegs base, JSValueRegs brand); 262 263 MacroAssembler::Jump slowPathJump() const 264 { 265 ASSERT(m_slowPathJump.m_jump.isSet()); 266 return m_slowPathJump.m_jump; 267 } 268 269 void finalize( 270 LinkBuffer& fastPathLinkBuffer, LinkBuffer& slowPathLinkBuffer); 271 272 void generateFastPath(MacroAssembler&); 273 274 private: 251 275 MacroAssembler::Label m_start; 252 276 MacroAssembler::PatchableJump m_slowPathJump; -
trunk/Source/JavaScriptCore/jit/JITOperations.cpp
r271987 r272580 1093 1093 RELEASE_ASSERT(baseValue.isObject()); 1094 1094 directPutByVal(globalObject, asObject(baseValue), subscript, value, byValInfo, ecmaMode); 1095 } 1096 1097 JSC_DEFINE_JIT_OPERATION(operationSetPrivateBrandOptimize, void, (JSGlobalObject* globalObject, StructureStubInfo* stubInfo, EncodedJSValue encodedBaseValue, EncodedJSValue encodedBrand)) 1098 { 1099 VM& vm = globalObject->vm(); 1100 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1101 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1102 auto scope = DECLARE_THROW_SCOPE(vm); 1103 1104 JSValue baseValue = JSValue::decode(encodedBaseValue); 1105 JSValue brand = JSValue::decode(encodedBrand); 1106 1107 ASSERT(baseValue.isObject()); 1108 ASSERT(brand.isSymbol()); 1109 1110 JSObject* baseObject = asObject(baseValue); 1111 Structure* oldStructure = baseObject->structure(vm); 1112 baseObject->setPrivateBrand(globalObject, brand); 1113 RETURN_IF_EXCEPTION(scope, void()); 1114 1115 CodeBlock* codeBlock = callFrame->codeBlock(); 1116 if (CacheableIdentifier::isCacheableIdentifierCell(brand)) { 1117 CacheableIdentifier identifier = CacheableIdentifier::createFromCell(brand.asCell()); 1118 if (stubInfo->considerCachingBy(vm, codeBlock, baseObject->structure(vm), identifier)) 1119 repatchSetPrivateBrand(globalObject, codeBlock, baseObject, oldStructure, identifier, *stubInfo); 1120 } 1121 1122 } 1123 1124 JSC_DEFINE_JIT_OPERATION(operationSetPrivateBrandGeneric, void, (JSGlobalObject* globalObject, StructureStubInfo* stubInfo, EncodedJSValue encodedBaseValue, EncodedJSValue encodedBrand)) 1125 { 1126 VM& vm = globalObject->vm(); 1127 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1128 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1129 auto scope = DECLARE_THROW_SCOPE(vm); 1130 1131 JSValue baseValue = JSValue::decode(encodedBaseValue); 1132 JSValue brand = JSValue::decode(encodedBrand); 1133 1134 if (stubInfo) 1135 stubInfo->tookSlowPath = true; 1136 1137 ASSERT(baseValue.isObject()); 1138 ASSERT(brand.isSymbol()); 1139 1140 JSObject* baseObject = asObject(baseValue); 1141 baseObject->setPrivateBrand(globalObject, brand); 1142 RETURN_IF_EXCEPTION(scope, void()); 1143 } 1144 1145 JSC_DEFINE_JIT_OPERATION(operationCheckPrivateBrandOptimize, void, (JSGlobalObject* globalObject, StructureStubInfo* stubInfo, EncodedJSValue encodedBaseValue, EncodedJSValue encodedBrand)) 1146 { 1147 VM& vm = globalObject->vm(); 1148 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1149 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1150 auto scope = DECLARE_THROW_SCOPE(vm); 1151 1152 JSValue baseValue = JSValue::decode(encodedBaseValue); 1153 JSValue brand = JSValue::decode(encodedBrand); 1154 1155 JSObject* baseObject = baseValue.toObject(globalObject); 1156 RETURN_IF_EXCEPTION(scope, void()); 1157 1158 ASSERT(brand.isSymbol()); 1159 1160 baseObject->checkPrivateBrand(globalObject, brand); 1161 RETURN_IF_EXCEPTION(scope, void()); 1162 1163 CodeBlock* codeBlock = callFrame->codeBlock(); 1164 if (CacheableIdentifier::isCacheableIdentifierCell(brand)) { 1165 CacheableIdentifier identifier = CacheableIdentifier::createFromCell(brand.asCell()); 1166 if (stubInfo->considerCachingBy(vm, codeBlock, baseObject->structure(vm), identifier)) 1167 repatchCheckPrivateBrand(globalObject, codeBlock, baseObject, identifier, *stubInfo); 1168 } 1169 } 1170 1171 JSC_DEFINE_JIT_OPERATION(operationCheckPrivateBrandGeneric, void, (JSGlobalObject* globalObject, StructureStubInfo* stubInfo, EncodedJSValue encodedBaseValue, EncodedJSValue encodedBrand)) 1172 { 1173 VM& vm = globalObject->vm(); 1174 CallFrame* callFrame = DECLARE_CALL_FRAME(vm); 1175 JITOperationPrologueCallFrameTracer tracer(vm, callFrame); 1176 auto scope = DECLARE_THROW_SCOPE(vm); 1177 1178 JSValue baseValue = JSValue::decode(encodedBaseValue); 1179 JSValue brand = JSValue::decode(encodedBrand); 1180 1181 stubInfo->tookSlowPath = true; 1182 1183 JSObject* baseObject = baseValue.toObject(globalObject); 1184 RETURN_IF_EXCEPTION(scope, void()); 1185 1186 ASSERT(brand.isSymbol()); 1187 1188 baseObject->checkPrivateBrand(globalObject, brand); 1189 RETURN_IF_EXCEPTION(scope, void()); 1095 1190 } 1096 1191 … … 2277 2372 2278 2373 JSObject* base = baseValue.toObject(globalObject); 2374 RETURN_IF_EXCEPTION(scope, JSValue()); 2375 2279 2376 PropertySlot slot(base, PropertySlot::InternalMethodType::GetOwnProperty); 2280 2377 base->getPrivateField(globalObject, fieldName, slot); … … 2383 2480 } 2384 2481 2385 return JSValue::encode(getPrivateName(globalObject, callFrame, baseValue, fieldName));2482 RELEASE_AND_RETURN(scope, JSValue::encode(getPrivateName(globalObject, callFrame, baseValue, fieldName))); 2386 2483 } 2387 2484 -
trunk/Source/JavaScriptCore/jit/JITOperations.h
r270874 r272580 193 193 JSC_DECLARE_JIT_OPERATION(operationPutByIdSetPrivateFieldStrictOptimize, void, (JSGlobalObject*, StructureStubInfo*, EncodedJSValue encodedValue, EncodedJSValue encodedBase, uintptr_t)); 194 194 195 JSC_DECLARE_JIT_OPERATION(operationSetPrivateBrandOptimize, void, (JSGlobalObject*, StructureStubInfo*, EncodedJSValue, EncodedJSValue)); 196 JSC_DECLARE_JIT_OPERATION(operationCheckPrivateBrandOptimize, void, (JSGlobalObject*, StructureStubInfo*, EncodedJSValue, EncodedJSValue)); 197 JSC_DECLARE_JIT_OPERATION(operationSetPrivateBrandGeneric, void, (JSGlobalObject*, StructureStubInfo*, EncodedJSValue, EncodedJSValue)); 198 JSC_DECLARE_JIT_OPERATION(operationCheckPrivateBrandGeneric, void, (JSGlobalObject*, StructureStubInfo*, EncodedJSValue, EncodedJSValue)); 199 195 200 JSC_DECLARE_JIT_OPERATION(operationPutPrivateNameOptimize, void, (JSGlobalObject*, EncodedJSValue, EncodedJSValue, EncodedJSValue, ByValInfo*, PrivateFieldPutKind)); 196 201 JSC_DECLARE_JIT_OPERATION(operationPutPrivateNameGeneric, void, (JSGlobalObject*, EncodedJSValue, EncodedJSValue, EncodedJSValue, ByValInfo*, PrivateFieldPutKind)); -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r272170 r272580 140 140 Label coldPathBegin = label(); 141 141 Call call = callOperationWithProfile(bytecode.metadata(m_codeBlock), operationGetPrivateNameOptimize, dst, TrustedImmPtr(m_codeBlock->globalObject()), gen.stubInfo(), baseGPR, propertyGPR); 142 gen.reportSlowPathCall(coldPathBegin, call); 143 } 144 145 void JIT::emit_op_set_private_brand(const Instruction* currentInstruction) 146 { 147 auto bytecode = currentInstruction->as<OpSetPrivateBrand>(); 148 VirtualRegister base = bytecode.m_base; 149 VirtualRegister brand = bytecode.m_brand; 150 GPRReg baseGPR = regT0; 151 GPRReg brandGPR = regT1; 152 emitGetVirtualRegister(base, baseGPR); 153 emitGetVirtualRegister(brand, brandGPR); 154 155 emitJumpSlowCaseIfNotJSCell(baseGPR, base); 156 157 JITPrivateBrandAccessGenerator gen( 158 m_codeBlock, CodeOrigin(m_bytecodeIndex), CallSiteIndex(m_bytecodeIndex), AccessType::SetPrivateBrand, RegisterSet::stubUnavailableRegisters(), 159 JSValueRegs(baseGPR), JSValueRegs(brandGPR)); 160 gen.generateFastPath(*this); 161 addSlowCase(gen.slowPathJump()); 162 m_privateBrandAccesses.append(gen); 163 164 // We should emit write-barrier at the end of sequence since write-barrier clobbers registers. 165 // IC can write new Structure without write-barrier if a base is cell. 166 // FIXME: Use UnconditionalWriteBarrier in Baseline effectively to reduce code size. 167 // https://bugs.webkit.org/show_bug.cgi?id=209395 168 emitWriteBarrier(base, ShouldFilterBase); 169 } 170 171 void JIT::emitSlow_op_set_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator& iter) 172 { 173 GPRReg baseGPR = regT0; 174 GPRReg brandGPR = regT1; 175 176 linkAllSlowCases(iter); 177 178 JITPrivateBrandAccessGenerator& gen = m_privateBrandAccesses[m_privateBrandAccessIndex]; 179 ++m_privateBrandAccessIndex; 180 Label coldPathBegin = label(); 181 Call call = callOperation(operationSetPrivateBrandOptimize, TrustedImmPtr(m_codeBlock->globalObject()), gen.stubInfo(), baseGPR, brandGPR); 182 gen.reportSlowPathCall(coldPathBegin, call); 183 } 184 185 void JIT::emit_op_check_private_brand(const Instruction* currentInstruction) 186 { 187 auto bytecode = currentInstruction->as<OpCheckPrivateBrand>(); 188 VirtualRegister base = bytecode.m_base; 189 VirtualRegister brand = bytecode.m_brand; 190 191 emitGetVirtualRegister(base, regT0); 192 emitGetVirtualRegister(brand, regT1); 193 194 emitJumpSlowCaseIfNotJSCell(regT0, base); 195 196 JITPrivateBrandAccessGenerator gen( 197 m_codeBlock, CodeOrigin(m_bytecodeIndex), CallSiteIndex(m_bytecodeIndex), AccessType::CheckPrivateBrand, RegisterSet::stubUnavailableRegisters(), 198 JSValueRegs(regT0), JSValueRegs(regT1)); 199 gen.generateFastPath(*this); 200 addSlowCase(gen.slowPathJump()); 201 m_privateBrandAccesses.append(gen); 202 } 203 204 void JIT::emitSlow_op_check_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator& iter) 205 { 206 GPRReg baseGPR = regT0; 207 GPRReg brandGPR = regT1; 208 209 linkAllSlowCases(iter); 210 211 JITPrivateBrandAccessGenerator& gen = m_privateBrandAccesses[m_privateBrandAccessIndex]; 212 ++m_privateBrandAccessIndex; 213 Label coldPathBegin = label(); 214 Call call = callOperation(operationCheckPrivateBrandOptimize, TrustedImmPtr(m_codeBlock->globalObject()), gen.stubInfo(), baseGPR, brandGPR); 142 215 gen.reportSlowPathCall(coldPathBegin, call); 143 216 } -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r270711 r272580 379 379 m_byValCompilationInfo[m_byValInstructionIndex].returnAddress = call; 380 380 m_byValInstructionIndex++; 381 } 382 383 void JIT::emit_op_set_private_brand(const Instruction* currentInstruction) 384 { 385 auto bytecode = currentInstruction->as<OpSetPrivateBrand>(); 386 VirtualRegister base = bytecode.m_base; 387 VirtualRegister brand = bytecode.m_brand; 388 JSValueRegs baseRegs(regT1, regT0); 389 JSValueRegs brandRegs(regT3, regT2); 390 emitLoad(base, baseRegs.tagGPR(), baseRegs.payloadGPR()); 391 emitLoad(brand, brandRegs.tagGPR(), brandRegs.payloadGPR()); 392 393 emitJumpSlowCaseIfNotJSCell(base, baseRegs.tagGPR()); 394 395 JITPrivateBrandAccessGenerator gen( 396 m_codeBlock, CodeOrigin(m_bytecodeIndex), CallSiteIndex(m_bytecodeIndex), AccessType::SetPrivateBrand, RegisterSet::stubUnavailableRegisters(), 397 baseRegs, brandRegs); 398 gen.generateFastPath(*this); 399 addSlowCase(gen.slowPathJump()); 400 m_privateBrandAccesses.append(gen); 401 402 // We should emit write-barrier at the end of sequence since write-barrier clobbers registers. 403 // IC can write new Structure without write-barrier if a base is cell. 404 // FIXME: Use UnconditionalWriteBarrier in Baseline effectively to reduce code size. 405 // https://bugs.webkit.org/show_bug.cgi?id=209395 406 emitWriteBarrier(base, ShouldFilterBase); 407 } 408 409 void JIT::emitSlow_op_set_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator& iter) 410 { 411 JSValueRegs baseRegs(regT1, regT0); 412 JSValueRegs brandRegs(regT3, regT2); 413 414 linkAllSlowCases(iter); 415 416 JITPrivateBrandAccessGenerator& gen = m_privateBrandAccesses[m_privateBrandAccessIndex]; 417 ++m_privateBrandAccessIndex; 418 Label coldPathBegin = label(); 419 Call call = callOperation(operationSetPrivateBrandOptimize, TrustedImmPtr(m_codeBlock->globalObject()), gen.stubInfo(), baseRegs, brandRegs); 420 gen.reportSlowPathCall(coldPathBegin, call); 421 } 422 423 void JIT::emit_op_check_private_brand(const Instruction* currentInstruction) 424 { 425 auto bytecode = currentInstruction->as<OpCheckPrivateBrand>(); 426 VirtualRegister base = bytecode.m_base; 427 VirtualRegister brand = bytecode.m_brand; 428 JSValueRegs baseRegs(regT1, regT0); 429 JSValueRegs brandRegs(regT3, regT2); 430 emitLoad(base, baseRegs.tagGPR(), baseRegs.payloadGPR()); 431 emitLoad(brand, brandRegs.tagGPR(), brandRegs.payloadGPR()); 432 433 emitJumpSlowCaseIfNotJSCell(base, baseRegs.tagGPR()); 434 435 JITPrivateBrandAccessGenerator gen( 436 m_codeBlock, CodeOrigin(m_bytecodeIndex), CallSiteIndex(m_bytecodeIndex), AccessType::CheckPrivateBrand, RegisterSet::stubUnavailableRegisters(), 437 baseRegs, brandRegs); 438 gen.generateFastPath(*this); 439 addSlowCase(gen.slowPathJump()); 440 m_privateBrandAccesses.append(gen); 441 } 442 443 void JIT::emitSlow_op_check_private_brand(const Instruction*, Vector<SlowCaseEntry>::iterator& iter) 444 { 445 JSValueRegs baseRegs(regT1, regT0); 446 JSValueRegs brandRegs(regT3, regT2); 447 448 linkAllSlowCases(iter); 449 450 JITPrivateBrandAccessGenerator& gen = m_privateBrandAccesses[m_privateBrandAccessIndex]; 451 ++m_privateBrandAccessIndex; 452 Label coldPathBegin = label(); 453 Call call = callOperation(operationCheckPrivateBrandOptimize, TrustedImmPtr(m_codeBlock->globalObject()), gen.stubInfo(), baseRegs, brandRegs); 454 gen.reportSlowPathCall(coldPathBegin, call); 381 455 } 382 456 -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r272170 r272580 1011 1011 } 1012 1012 1013 static InlineCacheAction tryCacheCheckPrivateBrand( 1014 JSGlobalObject* globalObject, CodeBlock* codeBlock, JSObject* base, CacheableIdentifier brandID, 1015 StructureStubInfo& stubInfo) 1016 { 1017 VM& vm = globalObject->vm(); 1018 AccessGenerationResult result; 1019 Identifier ident = Identifier::fromUid(vm, brandID.uid()); 1020 1021 { 1022 GCSafeConcurrentJSLocker locker(codeBlock->m_lock, vm.heap); 1023 if (forceICFailure(globalObject)) 1024 return GiveUpOnCache; 1025 1026 Structure* structure = base->structure(vm); 1027 1028 InlineCacheAction action = actionForCell(vm, base); 1029 if (action != AttemptToCache) 1030 return action; 1031 1032 bool isBaseProperty = true; 1033 LOG_IC((ICEvent::CheckPrivateBrandAddAccessCase, structure->classInfo(), ident, isBaseProperty)); 1034 1035 std::unique_ptr<AccessCase> newCase = AccessCase::createCheckPrivateBrand(vm, codeBlock, brandID, structure); 1036 1037 result = stubInfo.addAccessCase(locker, globalObject, codeBlock, ECMAMode::strict(), brandID, WTFMove(newCase)); 1038 1039 if (result.generatedSomeCode()) { 1040 LOG_IC((ICEvent::CheckPrivateBrandReplaceWithJump, structure->classInfo(), ident, isBaseProperty)); 1041 1042 RELEASE_ASSERT(result.code()); 1043 InlineAccess::rewireStubAsJump(stubInfo, CodeLocationLabel<JITStubRoutinePtrTag>(result.code())); 1044 } 1045 } 1046 1047 fireWatchpointsAndClearStubIfNeeded(vm, stubInfo, codeBlock, result); 1048 1049 return result.shouldGiveUpNow() ? GiveUpOnCache : RetryCacheLater; 1050 } 1051 1052 void repatchCheckPrivateBrand(JSGlobalObject* globalObject, CodeBlock* codeBlock, JSObject* baseObject, CacheableIdentifier brandID, StructureStubInfo& stubInfo) 1053 { 1054 SuperSamplerScope superSamplerScope(false); 1055 1056 if (tryCacheCheckPrivateBrand(globalObject, codeBlock, baseObject, brandID, stubInfo) == GiveUpOnCache) 1057 ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation, operationCheckPrivateBrandGeneric); 1058 } 1059 1060 static InlineCacheAction tryCacheSetPrivateBrand( 1061 JSGlobalObject* globalObject, CodeBlock* codeBlock, JSObject* base, Structure* oldStructure, CacheableIdentifier brandID, 1062 StructureStubInfo& stubInfo) 1063 { 1064 VM& vm = globalObject->vm(); 1065 AccessGenerationResult result; 1066 Identifier ident = Identifier::fromUid(vm, brandID.uid()); 1067 1068 { 1069 GCSafeConcurrentJSLocker locker(codeBlock->m_lock, vm.heap); 1070 if (forceICFailure(globalObject)) 1071 return GiveUpOnCache; 1072 1073 ASSERT(oldStructure); 1074 1075 if (oldStructure->isDictionary()) 1076 return RetryCacheLater; 1077 1078 InlineCacheAction action = actionForCell(vm, base); 1079 if (action != AttemptToCache) 1080 return action; 1081 1082 Structure* newStructure = Structure::setBrandTransitionFromExistingStructureConcurrently(oldStructure, brandID.uid()); 1083 if (!newStructure) 1084 return RetryCacheLater; 1085 if (newStructure->isDictionary()) 1086 return GiveUpOnCache; 1087 ASSERT(newStructure->previousID() == oldStructure); 1088 ASSERT(newStructure->transitionKind() == TransitionKind::SetBrand); 1089 ASSERT(newStructure->isObject()); 1090 1091 bool isBaseProperty = true; 1092 LOG_IC((ICEvent::SetPrivateBrandAddAccessCase, oldStructure->classInfo(), ident, isBaseProperty)); 1093 1094 std::unique_ptr<AccessCase> newCase = AccessCase::createSetPrivateBrand(vm, codeBlock, brandID, oldStructure, newStructure); 1095 1096 result = stubInfo.addAccessCase(locker, globalObject, codeBlock, ECMAMode::strict(), brandID, WTFMove(newCase)); 1097 1098 if (result.generatedSomeCode()) { 1099 LOG_IC((ICEvent::SetPrivateBrandReplaceWithJump, oldStructure->classInfo(), ident, isBaseProperty)); 1100 1101 RELEASE_ASSERT(result.code()); 1102 InlineAccess::rewireStubAsJump(stubInfo, CodeLocationLabel<JITStubRoutinePtrTag>(result.code())); 1103 } 1104 } 1105 1106 fireWatchpointsAndClearStubIfNeeded(vm, stubInfo, codeBlock, result); 1107 1108 return result.shouldGiveUpNow() ? GiveUpOnCache : RetryCacheLater; 1109 } 1110 1111 void repatchSetPrivateBrand(JSGlobalObject* globalObject, CodeBlock* codeBlock, JSObject* baseObject, Structure* oldStructure, CacheableIdentifier brandID, StructureStubInfo& stubInfo) 1112 { 1113 SuperSamplerScope superSamplerScope(false); 1114 1115 if (tryCacheSetPrivateBrand(globalObject, codeBlock, baseObject, oldStructure, brandID, stubInfo) == GiveUpOnCache) 1116 ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation, operationSetPrivateBrandGeneric); 1117 } 1118 1013 1119 static InlineCacheAction tryCacheInstanceOf( 1014 1120 JSGlobalObject* globalObject, CodeBlock* codeBlock, JSValue valueValue, JSValue prototypeValue, StructureStubInfo& stubInfo, … … 1586 1692 } 1587 1693 1694 void resetCheckPrivateBrand(CodeBlock* codeBlock, StructureStubInfo& stubInfo) 1695 { 1696 ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation, operationCheckPrivateBrandOptimize); 1697 InlineAccess::rewireStubAsJump(stubInfo, stubInfo.slowPathStartLocation); 1698 } 1699 1700 void resetSetPrivateBrand(CodeBlock* codeBlock, StructureStubInfo& stubInfo) 1701 { 1702 ftlThunkAwareRepatchCall(codeBlock, stubInfo.slowPathCallLocation, operationSetPrivateBrandOptimize); 1703 InlineAccess::rewireStubAsJump(stubInfo, stubInfo.slowPathStartLocation); 1704 } 1705 1588 1706 MacroAssemblerCodePtr<JSEntryPtrTag> jsToWasmICCodePtr(VM& vm, CodeSpecializationKind kind, JSObject* callee) 1589 1707 { -
trunk/Source/JavaScriptCore/jit/Repatch.h
r268794 r272580 54 54 void repatchDeleteBy(JSGlobalObject*, CodeBlock*, DeletePropertySlot&, JSValue, Structure*, CacheableIdentifier, StructureStubInfo&, DelByKind, ECMAMode); 55 55 void repatchInByID(JSGlobalObject*, CodeBlock*, JSObject*, CacheableIdentifier, bool wasFound, const PropertySlot&, StructureStubInfo&); 56 void repatchCheckPrivateBrand(JSGlobalObject*, CodeBlock*, JSObject*, CacheableIdentifier, StructureStubInfo&); 57 void repatchSetPrivateBrand(JSGlobalObject*, CodeBlock*, JSObject*, Structure*, CacheableIdentifier, StructureStubInfo&); 56 58 void repatchInstanceOf(JSGlobalObject*, CodeBlock*, JSValue value, JSValue prototype, StructureStubInfo&, bool wasFound); 57 59 void linkFor(VM&, CallFrame*, CallLinkInfo&, CodeBlock*, JSObject* callee, MacroAssemblerCodePtr<JSEntryPtrTag>); … … 65 67 void resetInByID(CodeBlock*, StructureStubInfo&); 66 68 void resetInstanceOf(StructureStubInfo&); 69 void resetCheckPrivateBrand(CodeBlock*, StructureStubInfo&); 70 void resetSetPrivateBrand(CodeBlock*, StructureStubInfo&); 67 71 void ftlThunkAwareRepatchCall(CodeBlock*, CodeLocationCall<JSInternalPtrTag>, FunctionPtr<CFunctionPtrTag> newCalleeFunction); 68 72 MacroAssemblerCodePtr<JSEntryPtrTag> jsToWasmICCodePtr(VM&, CodeSpecializationKind, JSObject* callee); -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r271987 r272580 1302 1302 } 1303 1303 1304 LLINT_SLOW_PATH_DECL(slow_path_set_private_brand) 1305 { 1306 LLINT_BEGIN(); 1307 1308 auto bytecode = pc->as<OpSetPrivateBrand>(); 1309 JSValue baseValue = getOperand(callFrame, bytecode.m_base); 1310 JSValue brand = getOperand(callFrame, bytecode.m_brand); 1311 auto& metadata = bytecode.metadata(codeBlock); 1312 ASSERT(baseValue.isObject()); 1313 ASSERT(brand.isSymbol()); 1314 1315 JSObject* baseObject = asObject(baseValue); 1316 Structure* oldStructure = baseObject->structure(vm); 1317 1318 baseObject->setPrivateBrand(globalObject, brand); 1319 LLINT_CHECK_EXCEPTION(); 1320 1321 if (!LLINT_ALWAYS_ACCESS_SLOW && !oldStructure->isDictionary()) { 1322 GCSafeConcurrentJSLocker locker(codeBlock->m_lock, vm.heap); 1323 Structure* newStructure = baseObject->structure(vm); 1324 1325 ASSERT(oldStructure == newStructure->previousID()); 1326 ASSERT(oldStructure->transitionWatchpointSetHasBeenInvalidated()); 1327 1328 // Start out by clearing out the old cache. 1329 metadata.m_oldStructureID = 0; 1330 metadata.m_newStructureID = 0; 1331 metadata.m_brand.clear(); 1332 1333 if (!newStructure->isDictionary()) { 1334 metadata.m_oldStructureID = oldStructure->id(); 1335 metadata.m_newStructureID = newStructure->id(); 1336 metadata.m_brand.set(vm, codeBlock, brand.asCell()); 1337 } 1338 vm.heap.writeBarrier(codeBlock); 1339 } 1340 1341 LLINT_END(); 1342 } 1343 1344 LLINT_SLOW_PATH_DECL(slow_path_check_private_brand) 1345 { 1346 LLINT_BEGIN(); 1347 1348 auto bytecode = pc->as<OpCheckPrivateBrand>(); 1349 auto& metadata = bytecode.metadata(codeBlock); 1350 JSValue baseValue = getOperand(callFrame, bytecode.m_base); 1351 JSValue brand = getOperand(callFrame, bytecode.m_brand); 1352 1353 JSObject* baseObject = baseValue.toObject(globalObject); 1354 LLINT_CHECK_EXCEPTION(); 1355 1356 ASSERT(brand.isSymbol()); 1357 1358 baseObject->checkPrivateBrand(globalObject, brand); 1359 LLINT_CHECK_EXCEPTION(); 1360 1361 // Since a brand can't ever be removed from an object, it's safe to 1362 // rely on StructureID even if it's an uncacheable dictionary. 1363 Structure* structure = baseObject->structure(vm); 1364 if (!LLINT_ALWAYS_ACCESS_SLOW) { 1365 GCSafeConcurrentJSLocker locker(codeBlock->m_lock, vm.heap); 1366 1367 metadata.m_structureID = structure->id(); 1368 metadata.m_brand.set(vm, codeBlock, brand.asCell()); 1369 vm.heap.writeBarrier(codeBlock); 1370 } 1371 1372 LLINT_END(); 1373 } 1374 1304 1375 LLINT_SLOW_PATH_DECL(slow_path_del_by_val) 1305 1376 { -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h
r267808 r272580 78 78 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_by_val_direct); 79 79 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_private_name); 80 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_check_private_brand); 81 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_set_private_brand); 80 82 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_del_by_val); 81 83 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_getter_by_id); -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r271120 r272580 2992 2992 notSupported() 2993 2993 end) 2994 2995 2996 llintOpWithMetadata(op_check_private_brand, OpCheckPrivateBrand, macro (size, get, dispatch, metadata, return) 2997 metadata(t5, t2) 2998 get(m_base, t3) 2999 loadConstantOrVariablePayload(size, t3, CellTag, t0, .opCheckPrivateBrandSlow) 3000 get(m_brand, t3) 3001 loadConstantOrVariablePayload(size, t3, CellTag, t1, .opCheckPrivateBrandSlow) 3002 3003 loadi OpCheckPrivateBrand::Metadata::m_structureID[t5], t3 3004 bineq JSCell::m_structureID[t0], t3, .opCheckPrivateBrandSlow 3005 3006 loadp OpCheckPrivateBrand::Metadata::m_brand[t5], t3 3007 bpneq t3, t1, .opCheckPrivateBrandSlow 3008 dispatch() 3009 3010 .opCheckPrivateBrandSlow: 3011 callSlowPath(_llint_slow_path_check_private_brand) 3012 dispatch() 3013 end) 3014 3015 3016 llintOpWithMetadata(op_set_private_brand, OpSetPrivateBrand, macro (size, get, dispatch, metadata, return) 3017 metadata(t5, t2) 3018 get(m_base, t3) 3019 loadConstantOrVariablePayload(size, t3, CellTag, t0, .opSetPrivateBrandSlow) 3020 get(m_brand, t3) 3021 loadConstantOrVariablePayload(size, t3, CellTag, t1, .opSetPrivateBrandSlow) 3022 3023 loadi OpSetPrivateBrand::Metadata::m_oldStructureID[t5], t2 3024 bineq t2, JSCell::m_structureID[t0], .opSetPrivateBrandSlow 3025 3026 loadp OpSetPrivateBrand::Metadata::m_brand[t5], t3 3027 bpneq t3, t1, .opSetPrivateBrandSlow 3028 3029 loadi OpSetPrivateBrand::Metadata::m_newStructureID[t5], t1 3030 storei t1, JSCell::m_structureID[t0] 3031 writeBarrierOnOperand(size, get, m_base) 3032 dispatch() 3033 3034 .opSetPrivateBrandSlow: 3035 callSlowPath(_llint_slow_path_set_private_brand) 3036 dispatch() 3037 end) 3038 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r271120 r272580 1813 1813 .opPutPrivateNameSlow: 1814 1814 callSlowPath(_llint_slow_path_put_private_name) 1815 dispatch() 1816 end) 1817 1818 llintOpWithMetadata(op_set_private_brand, OpSetPrivateBrand, macro (size, get, dispatch, metadata, return) 1819 get(m_base, t3) 1820 loadConstantOrVariableCell(size, t3, t0, .opSetPrivateBrandSlow) 1821 get(m_brand, t3) 1822 loadConstantOrVariableCell(size, t3, t1, .opSetPrivateBrandSlow) 1823 metadata(t5, t2) 1824 loadi OpSetPrivateBrand::Metadata::m_oldStructureID[t5], t2 1825 bineq t2, JSCell::m_structureID[t0], .opSetPrivateBrandSlow 1826 1827 loadp OpSetPrivateBrand::Metadata::m_brand[t5], t3 1828 bpneq t3, t1, .opSetPrivateBrandSlow 1829 1830 loadi OpSetPrivateBrand::Metadata::m_newStructureID[t5], t1 1831 storei t1, JSCell::m_structureID[t0] 1832 writeBarrierOnOperand(size, get, m_base) 1833 dispatch() 1834 1835 .opSetPrivateBrandSlow: 1836 callSlowPath(_llint_slow_path_set_private_brand) 1837 dispatch() 1838 end) 1839 1840 llintOpWithMetadata(op_check_private_brand, OpCheckPrivateBrand, macro (size, get, dispatch, metadata, return) 1841 metadata(t5, t2) 1842 get(m_base, t3) 1843 loadConstantOrVariableCell(size, t3, t0, .opCheckPrivateBrandSlow) 1844 get(m_brand, t3) 1845 loadConstantOrVariableCell(size, t3, t1, .opCheckPrivateBrandSlow) 1846 1847 loadp OpCheckPrivateBrand::Metadata::m_brand[t5], t3 1848 bqneq t3, t1, .opCheckPrivateBrandSlow 1849 1850 loadi OpCheckPrivateBrand::Metadata::m_structureID[t5], t2 1851 bineq t2, JSCell::m_structureID[t0], .opCheckPrivateBrandSlow 1852 dispatch() 1853 1854 .opCheckPrivateBrandSlow: 1855 callSlowPath(_llint_slow_path_check_private_brand) 1815 1856 dispatch() 1816 1857 end) -
trunk/Source/JavaScriptCore/parser/Nodes.cpp
r262613 r272580 203 203 , m_needsClassFieldInitializer(static_cast<unsigned>(NeedsClassFieldInitializer::No)) 204 204 , m_isArrowFunctionBodyExpression(isArrowFunctionBodyExpression) 205 , m_privateBrandRequirement(static_cast<unsigned>(PrivateBrandRequirement::None)) 205 206 , m_parseMode(mode) 206 207 , m_startColumn(startColumn) … … 227 228 , m_needsClassFieldInitializer(static_cast<unsigned>(NeedsClassFieldInitializer::No)) 228 229 , m_isArrowFunctionBodyExpression(isArrowFunctionBodyExpression) 230 , m_privateBrandRequirement(static_cast<unsigned>(PrivateBrandRequirement::None)) 229 231 , m_parseMode(mode) 230 232 , m_startColumn(startColumn) -
trunk/Source/JavaScriptCore/parser/Nodes.h
r271265 r272580 722 722 class PropertyNode final : public ParserArenaFreeable { 723 723 public: 724 enum Type : uint8_t { Constant = 1, Getter = 2, Setter = 4, Computed = 8, Shorthand = 16, Spread = 32, Private = 64};724 enum Type : uint8_t { Constant = 1, Getter = 2, Setter = 4, Computed = 8, Shorthand = 16, Spread = 32, PrivateField = 64, PrivateMethod = 128 }; 725 725 726 726 PropertyNode(const Identifier&, ExpressionNode*, Type, SuperBinding, ClassElementTag); … … 741 741 bool isStaticClassField() const { return isStaticClassProperty() && !needsSuperBinding(); } 742 742 bool isOverriddenByDuplicate() const { return m_isOverriddenByDuplicate; } 743 bool isPrivate() const { return m_type & Private; }743 bool isPrivate() const { return m_type & (PrivateField | PrivateMethod); } 744 744 bool hasComputedName() const { return m_expression; } 745 745 bool isComputedClassField() const { return isClassField() && hasComputedName(); } … … 761 761 ExpressionNode* m_expression; 762 762 ExpressionNode* m_assign; 763 unsigned m_type : 7;763 unsigned m_type; 764 764 unsigned m_needsSuperBinding : 1; 765 765 static_assert(1 << 2 > static_cast<unsigned>(ClassElementTag::LastTag), "ClassElementTag shouldn't use more than two bits"); … … 839 839 }; 840 840 841 enum class DotType { Name, Private Field};841 enum class DotType { Name, PrivateMember }; 842 842 class BaseDotNode : public ExpressionNode { 843 843 public: … … 847 847 const Identifier& identifier() const { return m_ident; } 848 848 DotType type() const { return m_type; } 849 bool isPrivate Field() const { return m_type == DotType::PrivateField; }849 bool isPrivateMember() const { return m_type == DotType::PrivateMember; } 850 850 851 851 RegisterID* emitGetPropertyValue(BytecodeGenerator&, RegisterID* dst, RegisterID* base, RefPtr<RegisterID>& thisValue); … … 871 871 872 872 bool isLocation() const final { return true; } 873 bool isPrivateLocation() const override { return m_type == DotType::Private Field; }873 bool isPrivateLocation() const override { return m_type == DotType::PrivateMember; } 874 874 bool isDotAccessorNode() const final { return true; } 875 875 }; … … 2162 2162 const Identifier& ecmaName() { return m_ident.isEmpty() ? m_ecmaName : m_ident; } 2163 2163 2164 void setPrivateBrandRequirement(PrivateBrandRequirement privateBrandRequirement) { m_privateBrandRequirement = static_cast<unsigned>(privateBrandRequirement); } 2165 PrivateBrandRequirement privateBrandRequirement() { return static_cast<PrivateBrandRequirement>(m_privateBrandRequirement); } 2166 2164 2167 FunctionMode functionMode() { return m_functionMode; } 2165 2168 … … 2210 2213 unsigned m_needsClassFieldInitializer : 1; 2211 2214 unsigned m_isArrowFunctionBodyExpression : 1; 2215 unsigned m_privateBrandRequirement : 1; 2212 2216 SourceParseMode m_parseMode; 2213 2217 FunctionMode m_functionMode; -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r272086 r272580 2871 2871 classScope->preventVarDeclarations(); 2872 2872 classScope->setStrictMode(); 2873 bool declaresPrivateMethod = false; 2873 2874 next(); 2874 2875 … … 2990 2991 case PRIVATENAME: { 2991 2992 ASSERT(Options::usePrivateClassFields()); 2992 JSToken token = m_token;2993 2993 ident = m_token.m_data.ident; 2994 2994 if (!Options::usePrivateStaticClassFields()) … … 2997 2997 ASSERT(ident); 2998 2998 next(); 2999 failIfTrue(matchAndUpdate(OPENPAREN, token), "Cannot parse class method with private name"); 3000 semanticFailIfTrue(classScope->declarePrivateName(*ident) & DeclarationResult::InvalidDuplicateDeclaration, "Cannot declare private field twice"); 3001 type = static_cast<PropertyNode::Type>(type | PropertyNode::Private); 2999 if (Options::usePrivateMethods() && match(OPENPAREN)) { 3000 semanticFailIfTrue(classScope->declarePrivateMethod(*ident) & DeclarationResult::InvalidDuplicateDeclaration, "Cannot declare private method twice"); 3001 declaresPrivateMethod = true; 3002 type = static_cast<PropertyNode::Type>(type | PropertyNode::PrivateMethod); 3003 break; 3004 } 3005 3006 failIfTrue(match(OPENPAREN), "Cannot parse class method with private name"); 3007 semanticFailIfTrue(classScope->declarePrivateField(*ident) & DeclarationResult::InvalidDuplicateDeclaration, "Cannot declare private field twice"); 3008 type = static_cast<PropertyNode::Type>(type | PropertyNode::PrivateField); 3002 3009 break; 3003 3010 } … … 3085 3092 consumeOrFail(CLOSEBRACE, "Expected a closing '}' after a class body"); 3086 3093 3094 if (declaresPrivateMethod) { 3095 Identifier privateBrandIdentifier = m_vm.propertyNames->builtinNames().privateBrandPrivateName(); 3096 DeclarationResultMask declarationResult = classScope->declareLexicalVariable(&privateBrandIdentifier, true); 3097 ASSERT_UNUSED(declarationResult, declarationResult == DeclarationResult::Valid); 3098 classScope->useVariable(&privateBrandIdentifier, false); 3099 classScope->addClosedVariableCandidateUnconditionally(privateBrandIdentifier.impl()); 3100 } 3101 3087 3102 if (Options::usePrivateClassFields()) { 3088 3103 // Fail if there are no parent private name scopes and any used-but-undeclared private names. 3089 3104 semanticFailIfFalse(copyUndeclaredPrivateNamesToOuterScope(), "Cannot reference undeclared private names"); 3090 3105 } 3106 3091 3107 auto classExpression = context.createClassExpr(location, info, classScope->finalizeLexicalEnvironment(), constructor, parentClass, classElements); 3092 3108 popScope(classScope, TreeBuilder::NeedsFreeVariableInfo); … … 5166 5182 m_parserState.lastPrivateName = ident; 5167 5183 currentScope()->useVariable(ident, false); 5168 type = DotType::Private Field;5184 type = DotType::PrivateMember; 5169 5185 m_token.m_type = IDENT; 5170 5186 } -
trunk/Source/JavaScriptCore/parser/Parser.h
r272086 r272580 501 501 } 502 502 503 DeclarationResultMask declarePrivate Name(const Identifier& ident)503 DeclarationResultMask declarePrivateMethod(const Identifier& ident) 504 504 { 505 505 ASSERT(m_allowsLexicalDeclarations); 506 506 DeclarationResultMask result = DeclarationResult::Valid; 507 auto addResult = m_lexicalVariables.declarePrivateName(ident); 507 bool addResult = m_lexicalVariables.declarePrivateMethod(ident); 508 509 if (!addResult) { 510 result |= DeclarationResult::InvalidDuplicateDeclaration; 511 return result; 512 } 513 514 useVariable(&ident, false); 515 addClosedVariableCandidateUnconditionally(ident.impl()); 516 517 return result; 518 } 519 520 DeclarationResultMask declarePrivateField(const Identifier& ident) 521 { 522 ASSERT(m_allowsLexicalDeclarations); 523 DeclarationResultMask result = DeclarationResult::Valid; 524 auto addResult = m_lexicalVariables.declarePrivateField(ident); 508 525 if (!addResult.isNewEntry) 509 526 result |= DeclarationResult::InvalidDuplicateDeclaration; … … 945 962 946 963 template <class ParsedNode> 947 std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const VariableEnvironment* = nullptr, const Vector<JSTextPosition>* = nullptr);964 std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const Vector<JSTextPosition>* = nullptr); 948 965 949 966 JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); } … … 2081 2098 template <typename LexerType> 2082 2099 template <class ParsedNode> 2083 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const VariableEnvironment* parentScopePrivateNames, const Vector<JSTextPosition>* classFieldLocations)2100 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const Vector<JSTextPosition>* classFieldLocations) 2084 2101 { 2085 2102 int errLine; … … 2097 2114 unsigned startColumn = m_source->startColumn().zeroBasedInt(); 2098 2115 2099 if (isEvalNode<ParsedNode>() && parentScopePrivateNames && parentScopePrivateNames-> privateNamesSize()) {2116 if (isEvalNode<ParsedNode>() && parentScopePrivateNames && parentScopePrivateNames->size()) { 2100 2117 currentScope()->setIsPrivateNameScope(); 2101 parentScopePrivateNames->copyPrivateNamesTo(currentScope()->lexicalVariables());2118 currentScope()->lexicalVariables().addPrivateNamesFrom(parentScopePrivateNames); 2102 2119 } 2103 2120 … … 2186 2203 EvalContextType evalContextType = EvalContextType::None, 2187 2204 DebuggerParseData* debuggerParseData = nullptr, 2188 const VariableEnvironment* parentScopePrivateNames = nullptr,2205 const PrivateNameEnvironment* parentScopePrivateNames = nullptr, 2189 2206 const Vector<JSTextPosition>* classFieldLocations = nullptr, 2190 2207 bool isInsideOrdinaryFunction = false) -
trunk/Source/JavaScriptCore/parser/ParserModes.h
r269922 r272580 38 38 enum class SuperBinding { Needed, NotNeeded }; 39 39 40 enum class PrivateBrandRequirement { None, Needed }; 41 40 42 enum class CodeGenerationMode : uint8_t { 41 43 Debugger = 1 << 0, -
trunk/Source/JavaScriptCore/parser/SyntaxChecker.h
r271265 r272580 180 180 ExpressionType createNull(const JSTokenLocation&) { return NullExpr; } 181 181 ExpressionType createBracketAccess(const JSTokenLocation&, ExpressionType, ExpressionType, bool, int, int, int) { return BracketExpr; } 182 ExpressionType createDotAccess(const JSTokenLocation&, ExpressionType, const Identifier*, DotType type, int, int, int) { return type == DotType::Private Field? PrivateDotExpr : DotExpr; }182 ExpressionType createDotAccess(const JSTokenLocation&, ExpressionType, const Identifier*, DotType type, int, int, int) { return type == DotType::PrivateMember ? PrivateDotExpr : DotExpr; } 183 183 ExpressionType createRegExp(const JSTokenLocation&, const Identifier& pattern, const Identifier& flags, int) { return Yarr::hasError(Yarr::checkSyntax(pattern.string(), flags.string())) ? 0 : RegExpExpr; } 184 184 ExpressionType createNewExpr(const JSTokenLocation&, ExpressionType, int, int, int, int) { return NewExpr; } -
trunk/Source/JavaScriptCore/parser/VariableEnvironment.cpp
r269115 r272580 105 105 } 106 106 107 bool VariableEnvironment::declarePrivateMethod(const RefPtr<UniquedStringImpl>& identifier) 108 { 109 if (!m_rareData) 110 m_rareData = makeUnique<VariableEnvironment::RareData>(); 111 112 auto findResult = m_rareData->m_privateNames.find(identifier); 113 114 if (findResult == m_rareData->m_privateNames.end()) { 115 PrivateNameEntry meta(PrivateNameEntry::Traits::IsDeclared | PrivateNameEntry::Traits::IsMethod); 116 117 auto entry = VariableEnvironmentEntry(); 118 entry.setIsPrivateMethod(); 119 entry.setIsConst(); 120 entry.setIsCaptured(); 121 m_map.add(identifier, entry); 122 123 auto addResult = m_rareData->m_privateNames.add(identifier, meta); 124 return addResult.isNewEntry; 125 } 126 127 if (findResult->value.isDeclared()) 128 return false; // Error: declaring a duplicate private name. 129 130 auto entry = VariableEnvironmentEntry(); 131 entry.setIsPrivateMethod(); 132 entry.setIsConst(); 133 entry.setIsCaptured(); 134 m_map.add(identifier, entry); 135 136 // it was previously used, mark it as declared. 137 PrivateNameEntry meta(PrivateNameEntry::Traits::IsDeclared | PrivateNameEntry::Traits::IsUsed | PrivateNameEntry::Traits::IsMethod); 138 auto addResult = m_rareData->m_privateNames.set(identifier, meta); 139 return !addResult.isNewEntry; 140 } 107 141 108 142 void CompactTDZEnvironment::sortCompact(Compact& compact) -
trunk/Source/JavaScriptCore/parser/VariableEnvironment.h
r270870 r272580 46 46 ALWAYS_INLINE bool isParameter() const { return m_bits & IsParameter; } 47 47 ALWAYS_INLINE bool isSloppyModeHoistingCandidate() const { return m_bits & IsSloppyModeHoistingCandidate; } 48 ALWAYS_INLINE bool isPrivateName() const { return m_bits & IsPrivateName; } 48 ALWAYS_INLINE bool isPrivateField() const { return m_bits & IsPrivateField; } 49 ALWAYS_INLINE bool isPrivateMethod() const { return m_bits & IsPrivateMethod; } 49 50 50 51 ALWAYS_INLINE void setIsCaptured() { m_bits |= IsCaptured; } … … 58 59 ALWAYS_INLINE void setIsParameter() { m_bits |= IsParameter; } 59 60 ALWAYS_INLINE void setIsSloppyModeHoistingCandidate() { m_bits |= IsSloppyModeHoistingCandidate; } 60 ALWAYS_INLINE void setIsPrivateName() { m_bits |= IsPrivateName; } 61 ALWAYS_INLINE void setIsPrivateField() { m_bits |= IsPrivateField; } 62 ALWAYS_INLINE void setIsPrivateMethod() { m_bits |= IsPrivateMethod; } 61 63 62 64 ALWAYS_INLINE void clearIsVar() { m_bits &= ~IsVar; } … … 81 83 IsParameter = 1 << 8, 82 84 IsSloppyModeHoistingCandidate = 1 << 9, 83 IsPrivateName = 1 << 10, 85 IsPrivateField = 1 << 10, 86 IsPrivateMethod = 1 << 11, 84 87 }; 85 88 uint16_t m_bits { 0 }; … … 91 94 92 95 struct PrivateNameEntry { 96 friend class CachedPrivateNameEntry; 97 93 98 public: 94 99 PrivateNameEntry(uint16_t traits = 0) { m_bits = traits; } … … 96 101 ALWAYS_INLINE bool isUsed() const { return m_bits & IsUsed; } 97 102 ALWAYS_INLINE bool isDeclared() const { return m_bits & IsDeclared; } 103 ALWAYS_INLINE bool isMethod() const { return m_bits & IsMethod; } 104 105 bool isPrivateMethodOrAcessor() const { return isMethod(); } 98 106 99 107 ALWAYS_INLINE void setIsUsed() { m_bits |= IsUsed; } … … 108 116 109 117 enum Traits : uint16_t { 118 None = 0, 110 119 IsUsed = 1 << 0, 111 120 IsDeclared = 1 << 1, 121 IsMethod = 1 << 2, 112 122 }; 113 123 … … 117 127 118 128 struct PrivateNameEntryHashTraits : HashTraits<PrivateNameEntry> { 119 static const bool needsDestruction = false; 120 }; 129 static constexpr bool needsDestruction = false; 130 }; 131 132 typedef HashMap<PackedRefPtr<UniquedStringImpl>, PrivateNameEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, PrivateNameEntryHashTraits> PrivateNameEnvironment; 121 133 122 134 class VariableEnvironment { … … 124 136 private: 125 137 typedef HashMap<PackedRefPtr<UniquedStringImpl>, VariableEnvironmentEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, VariableEnvironmentEntryHashTraits> Map; 126 typedef HashMap<PackedRefPtr<UniquedStringImpl>, PrivateNameEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, PrivateNameEntryHashTraits> PrivateNames; 138 127 139 public: 140 128 141 VariableEnvironment() { } 129 142 VariableEnvironment(VariableEnvironment&& other) … … 147 160 ALWAYS_INLINE Map::AddResult add(const RefPtr<UniquedStringImpl>& identifier) { return m_map.add(identifier, VariableEnvironmentEntry()); } 148 161 ALWAYS_INLINE Map::AddResult add(const Identifier& identifier) { return add(identifier.impl()); } 162 163 ALWAYS_INLINE PrivateNameEnvironment::AddResult addPrivateName(const Identifier& identifier) { return addPrivateName(identifier.impl()); } 164 ALWAYS_INLINE PrivateNameEnvironment::AddResult addPrivateName(const RefPtr<UniquedStringImpl>& identifier) 165 { 166 if (!m_rareData) 167 m_rareData = makeUnique<VariableEnvironment::RareData>(); 168 169 return m_rareData->m_privateNames.add(identifier, PrivateNameEntry()); 170 } 171 149 172 ALWAYS_INLINE unsigned size() const { return m_map.size() + privateNamesSize(); } 150 173 ALWAYS_INLINE unsigned mapSize() const { return m_map.size(); } … … 165 188 bool isEmpty() const { return !m_map.size(); } 166 189 167 using PrivateNamesRange = WTF::IteratorRange<PrivateName s::iterator>;168 169 ALWAYS_INLINE Map::AddResult declarePrivate Name(const Identifier& identifier) { return declarePrivateName(identifier.impl()); }190 using PrivateNamesRange = WTF::IteratorRange<PrivateNameEnvironment::iterator>; 191 192 ALWAYS_INLINE Map::AddResult declarePrivateField(const Identifier& identifier) { return declarePrivateField(identifier.impl()); } 170 193 ALWAYS_INLINE void usePrivateName(const Identifier& identifier) { usePrivateName(identifier.impl()); } 171 194 172 Map::AddResult declarePrivateName(const RefPtr<UniquedStringImpl>& identifier) 195 bool declarePrivateMethod(const Identifier& identifier) { return declarePrivateMethod(identifier.impl()); } 196 bool declarePrivateMethod(const RefPtr<UniquedStringImpl>& identifier); 197 198 Map::AddResult declarePrivateField(const RefPtr<UniquedStringImpl>& identifier) 173 199 { 174 200 auto& meta = getOrAddPrivateName(identifier.get()); 175 201 meta.setIsDeclared(); 176 202 auto entry = VariableEnvironmentEntry(); 177 entry.setIsPrivate Name();203 entry.setIsPrivateField(); 178 204 entry.setIsConst(); 179 205 entry.setIsCaptured(); … … 200 226 return 0; 201 227 return m_rareData->m_privateNames.size(); 228 } 229 230 ALWAYS_INLINE const PrivateNameEnvironment* privateNameEnvironment() const 231 { 232 if (!m_rareData) 233 return nullptr; 234 return &m_rareData->m_privateNames; 235 } 236 237 ALWAYS_INLINE bool hasPrivateMethodOrAccessor() const 238 { 239 if (!m_rareData) 240 return false; 241 242 for (auto entry : privateNames()) { 243 if (entry.value.isPrivateMethodOrAcessor()) 244 return true; 245 } 246 247 return false; 202 248 } 203 249 … … 220 266 other.m_rareData->m_privateNames.add(entry.key, entry.value); 221 267 } 268 } 269 } 270 271 ALWAYS_INLINE void addPrivateNamesFrom(const PrivateNameEnvironment* privateNameEnvironment) 272 { 273 if (!privateNameEnvironment) 274 return; 275 276 if (!m_rareData) 277 m_rareData = makeUnique<VariableEnvironment::RareData>(); 278 279 for (auto entry : *privateNameEnvironment) { 280 ASSERT(entry.value.isDeclared()); 281 m_rareData->m_privateNames.add(entry.key, entry.value); 222 282 } 223 283 } … … 245 305 RareData(const RareData&) = default; 246 306 RareData& operator=(const RareData&) = default; 247 PrivateName sm_privateNames;307 PrivateNameEnvironment m_privateNames; 248 308 }; 249 309 -
trunk/Source/JavaScriptCore/runtime/BrandedStructure.cpp
r272579 r272580 1 1 /* 2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 * Copyright (C) 2021 Igalia S.A. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 24 25 */ 25 26 26 #pragma once 27 #include "config.h" 28 #include "BrandedStructure.h" 27 29 28 #include " EvalExecutable.h"30 #include "JSCInlines.h" 29 31 30 32 namespace JSC { 31 33 32 class DirectEvalExecutable final : public EvalExecutable { 33 public: 34 static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, const TDZEnvironment* parentScopeTDZVariables, const VariableEnvironment* privateNames, ECMAMode); 35 private: 36 DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType); 37 }; 34 BrandedStructure::BrandedStructure(VM& vm, Structure* previous, UniquedStringImpl* brandUid, DeferredStructureTransitionWatchpointFire* deferred) 35 : Structure(vm, previous, deferred) 36 , m_brand(brandUid) 37 { 38 if (previous->isBrandedStructure()) 39 m_parentBrand.set(vm, this, jsCast<BrandedStructure*>(previous)); 40 this->setIsBrandedStructure(true); 41 } 38 42 39 static_assert(sizeof(DirectEvalExecutable) == sizeof(EvalExecutable), ""); 43 BrandedStructure::BrandedStructure(VM& vm, BrandedStructure* previous, DeferredStructureTransitionWatchpointFire* deferred) 44 : Structure(vm, previous, deferred) 45 , m_brand(previous->m_brand) 46 , m_parentBrand(vm, this, previous->m_parentBrand.get(), WriteBarrier<BrandedStructure>::MayBeNull) 47 { 48 this->setIsBrandedStructure(true); 49 } 50 51 Structure* BrandedStructure::create(VM& vm, Structure* previous, UniquedStringImpl* brandUid, DeferredStructureTransitionWatchpointFire* deferred) 52 { 53 ASSERT(vm.structureStructure); 54 BrandedStructure* newStructure = new (NotNull, allocateCell<BrandedStructure>(vm.heap)) BrandedStructure(vm, previous, brandUid, deferred); 55 newStructure->finishCreation(vm, previous); 56 return newStructure; 57 } 40 58 41 59 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/BrandedStructure.h
r272579 r272580 1 1 /* 2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 * Copyright (C) 2021 Igalia S.A. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 26 27 #pragma once 27 28 28 #include "EvalExecutable.h" 29 #include "Structure.h" 30 #include "Symbol.h" 31 #include "Watchpoint.h" 32 #include "WriteBarrierInlines.h" 33 34 namespace WTF { 35 36 class UniquedStringImpl; 37 38 } // namespace WTF 29 39 30 40 namespace JSC { 31 41 32 class DirectEvalExecutable final : public EvalExecutable { 42 class BrandedStructure final : public Structure { 43 typedef Structure Base; 44 33 45 public: 34 static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, const TDZEnvironment* parentScopeTDZVariables, const VariableEnvironment* privateNames, ECMAMode); 35 private: 36 DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType); 46 47 template<typename CellType, SubspaceAccess> 48 static IsoSubspace* subspaceFor(VM& vm) 49 { 50 return &vm.brandedStructureSpace; 51 } 52 53 ALWAYS_INLINE bool checkBrand(Symbol* brand) 54 { 55 UniquedStringImpl* brandUid = &brand->uid(); 56 for (BrandedStructure* currentStructure = this; currentStructure; currentStructure = currentStructure->m_parentBrand.get()) { 57 if (brandUid == currentStructure->m_brand) 58 return true; 59 } 60 return false; 61 } 62 63 private: 64 BrandedStructure(VM&, Structure*, UniquedStringImpl* brand, DeferredStructureTransitionWatchpointFire*); 65 BrandedStructure(VM&, BrandedStructure*, DeferredStructureTransitionWatchpointFire*); 66 67 static Structure* create(VM&, Structure*, UniquedStringImpl* brand, DeferredStructureTransitionWatchpointFire* = nullptr); 68 69 UniquedStringImpl* m_brand; 70 WriteBarrier<BrandedStructure> m_parentBrand; 71 72 friend class Structure; 37 73 }; 38 74 39 static_assert(sizeof(DirectEvalExecutable) == sizeof(EvalExecutable), "");40 41 75 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r270991 r272580 995 995 m_constantIdentifierSets.encode(encoder, rareData.m_constantIdentifierSets); 996 996 m_needsClassFieldInitializer = rareData.m_needsClassFieldInitializer; 997 m_privateBrandRequirement = rareData.m_privateBrandRequirement; 997 998 } 998 999 … … 1009 1010 m_constantIdentifierSets.decode(decoder, rareData->m_constantIdentifierSets); 1010 1011 rareData->m_needsClassFieldInitializer = m_needsClassFieldInitializer; 1012 rareData->m_privateBrandRequirement = m_privateBrandRequirement; 1011 1013 return rareData; 1012 1014 } … … 1022 1024 CachedVector<CachedConstantIdentifierSetEntry> m_constantIdentifierSets; 1023 1025 unsigned m_needsClassFieldInitializer : 1; 1024 }; 1026 unsigned m_privateBrandRequirement : 1; 1027 }; 1028 1029 typedef CachedHashMap<CachedRefPtr<CachedUniquedStringImpl, UniquedStringImpl, WTF::PackedPtrTraits<UniquedStringImpl>>, PrivateNameEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, PrivateNameEntryHashTraits> CachedPrivateNameEnvironment; 1025 1030 1026 1031 class CachedVariableEnvironmentRareData : public CachedObject<VariableEnvironment::RareData> { … … 1037 1042 1038 1043 private: 1039 Cached HashMap<CachedRefPtr<CachedUniquedStringImpl, UniquedStringImpl, WTF::PackedPtrTraits<UniquedStringImpl>>, PrivateNameEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, PrivateNameEntryHashTraits>m_privateNames;1044 CachedPrivateNameEnvironment m_privateNames; 1040 1045 }; 1041 1046 … … 1214 1219 1215 1220 private: 1216 Cached HashSet<CachedRefPtr<CachedUniquedStringImpl>, IdentifierRepHash>m_privateNames;1221 CachedPrivateNameEnvironment m_privateNames; 1217 1222 }; 1218 1223 … … 1791 1796 m_classSource.encode(encoder, rareData.m_classSource); 1792 1797 m_parentScopeTDZVariables.encode(encoder, rareData.m_parentScopeTDZVariables); 1798 m_parentPrivateNameEnvironment.encode(encoder, rareData.m_parentPrivateNameEnvironment); 1793 1799 } 1794 1800 … … 1798 1804 m_classSource.decode(decoder, rareData->m_classSource); 1799 1805 m_parentScopeTDZVariables.decode(decoder, rareData->m_parentScopeTDZVariables); 1806 m_parentPrivateNameEnvironment.decode(decoder, rareData->m_parentPrivateNameEnvironment); 1800 1807 return rareData; 1801 1808 } … … 1804 1811 CachedSourceCodeWithoutProvider m_classSource; 1805 1812 CachedRefPtr<CachedTDZEnvironmentLink> m_parentScopeTDZVariables; 1813 CachedPrivateNameEnvironment m_parentPrivateNameEnvironment; 1806 1814 }; 1807 1815 … … 1839 1847 unsigned derivedContextType() const { return m_derivedContextType; } 1840 1848 unsigned needsClassFieldInitializer() const { return m_needsClassFieldInitializer; } 1849 unsigned privateBrandRequirement() const { return m_privateBrandRequirement; } 1841 1850 1842 1851 Identifier name(Decoder& decoder) const { return m_name.decode(decoder); } … … 1867 1876 unsigned m_typeProfilingStartOffset; 1868 1877 unsigned m_typeProfilingEndOffset; 1869 unsigned m_parameterCount; 1878 unsigned m_parameterCount:31; 1879 unsigned m_privateBrandRequirement : 1; 1870 1880 SourceParseMode m_sourceParseMode; 1871 1881 unsigned m_constructorKind : 2; … … 1924 1934 unsigned constructorKind() const { return m_constructorKind; } 1925 1935 unsigned derivedContextType() const { return m_derivedContextType; } 1926 unsigned needsClassFieldInitializer() const { return m_needsClassFieldInitializer; }1927 1936 unsigned evalContextType() const { return m_evalContextType; } 1928 1937 unsigned hasTailCalls() const { return m_hasTailCalls; } … … 1956 1965 unsigned m_constructorKind : 2; 1957 1966 unsigned m_derivedContextType : 2; 1958 unsigned m_needsClassFieldInitializer : 1;1959 1967 unsigned m_evalContextType : 2; 1960 1968 unsigned m_hasTailCalls : 1; … … 2237 2245 m_derivedContextType = executable.m_derivedContextType; 2238 2246 m_needsClassFieldInitializer = executable.m_needsClassFieldInitializer; 2247 m_privateBrandRequirement = executable.m_privateBrandRequirement; 2239 2248 2240 2249 m_rareData.encode(encoder, executable.m_rareData.get()); … … 2278 2287 , m_typeProfilingEndOffset(cachedExecutable.typeProfilingEndOffset()) 2279 2288 , m_parameterCount(cachedExecutable.parameterCount()) 2289 , m_privateBrandRequirement(cachedExecutable.privateBrandRequirement()) 2280 2290 , m_features(cachedExecutable.features()) 2281 2291 , m_sourceParseMode(cachedExecutable.sourceParseMode()) -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r270870 r272580 72 72 73 73 template <class UnlinkedCodeBlockType, class ExecutableType = ScriptExecutable> 74 UnlinkedCodeBlockType* generateUnlinkedCodeBlockImpl(VM& vm, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, DerivedContextType derivedContextType, bool isArrowFunctionContext, const TDZEnvironment* variablesUnderTDZ = nullptr, const VariableEnvironment* parentScopePrivateNames= nullptr, ExecutableType* executable = nullptr)74 UnlinkedCodeBlockType* generateUnlinkedCodeBlockImpl(VM& vm, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, DerivedContextType derivedContextType, bool isArrowFunctionContext, const TDZEnvironment* variablesUnderTDZ = nullptr, const PrivateNameEnvironment* privateNameEnvironment = nullptr, ExecutableType* executable = nullptr) 75 75 { 76 76 typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode; … … 78 78 79 79 std::unique_ptr<RootNode> rootNode = parse<RootNode>( 80 vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin, strictMode, scriptMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, derivedContextType, evalContextType, nullptr, p arentScopePrivateNames, nullptr, isInsideOrdinaryFunction);80 vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin, strictMode, scriptMode, CacheTypes<UnlinkedCodeBlockType>::parseMode, SuperBinding::NotNeeded, error, nullptr, ConstructorKind::None, derivedContextType, evalContextType, nullptr, privateNameEnvironment, nullptr, isInsideOrdinaryFunction); 81 81 82 82 if (!rootNode) … … 95 95 ECMAMode ecmaMode = rootNode->features() & StrictModeFeature ? ECMAMode::strict() : ECMAMode::sloppy(); 96 96 NeedsClassFieldInitializer needsClassFieldInitializer = NeedsClassFieldInitializer::No; 97 if constexpr (std::is_same_v<ExecutableType, DirectEvalExecutable>) 97 PrivateBrandRequirement privateBrandRequirement = PrivateBrandRequirement::None; 98 if constexpr (std::is_same_v<ExecutableType, DirectEvalExecutable>) { 98 99 needsClassFieldInitializer = executable->needsClassFieldInitializer(); 99 ExecutableInfo executableInfo(usesEval, false, false, ConstructorKind::None, scriptMode, SuperBinding::NotNeeded, CacheTypes<UnlinkedCodeBlockType>::parseMode, derivedContextType, needsClassFieldInitializer, isArrowFunctionContext, false, evalContextType); 100 privateBrandRequirement = executable->privateBrandRequirement(); 101 } 102 ExecutableInfo executableInfo(usesEval, false, privateBrandRequirement, false, ConstructorKind::None, scriptMode, SuperBinding::NotNeeded, CacheTypes<UnlinkedCodeBlockType>::parseMode, derivedContextType, needsClassFieldInitializer, isArrowFunctionContext, false, evalContextType); 100 103 101 104 UnlinkedCodeBlockType* unlinkedCodeBlock = UnlinkedCodeBlockType::create(vm, executableInfo, codeGenerationMode); … … 109 112 if (variablesUnderTDZ) 110 113 parentVariablesUnderTDZ = TDZEnvironmentLink::create(vm.m_compactVariableMap->get(*variablesUnderTDZ), nullptr); 111 error = BytecodeGenerator::generate(vm, rootNode.get(), source, unlinkedCodeBlock, codeGenerationMode, parentVariablesUnderTDZ, ecmaMode);114 error = BytecodeGenerator::generate(vm, rootNode.get(), source, unlinkedCodeBlock, codeGenerationMode, parentVariablesUnderTDZ, privateNameEnvironment, ecmaMode); 112 115 113 116 if (error.isValid()) … … 118 121 119 122 template <class UnlinkedCodeBlockType, class ExecutableType> 120 UnlinkedCodeBlockType* generateUnlinkedCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ = nullptr, const VariableEnvironment* parentScopePrivateNames= nullptr)121 { 122 return generateUnlinkedCodeBlockImpl<UnlinkedCodeBlockType, ExecutableType>(vm, source, strictMode, scriptMode, codeGenerationMode, error, evalContextType, executable->derivedContextType(), executable->isArrowFunctionContext(), variablesUnderTDZ, p arentScopePrivateNames, executable);123 } 124 125 UnlinkedEvalCodeBlock* generateUnlinkedCodeBlockForDirectEval(VM& vm, DirectEvalExecutable* executable, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ, const VariableEnvironment* parentScopePrivateNames)126 { 127 return generateUnlinkedCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, strictMode, scriptMode, codeGenerationMode, error, evalContextType, variablesUnderTDZ, p arentScopePrivateNames);123 UnlinkedCodeBlockType* generateUnlinkedCodeBlock(VM& vm, ExecutableType* executable, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ = nullptr, const PrivateNameEnvironment* privateNameEnvironment = nullptr) 124 { 125 return generateUnlinkedCodeBlockImpl<UnlinkedCodeBlockType, ExecutableType>(vm, source, strictMode, scriptMode, codeGenerationMode, error, evalContextType, executable->derivedContextType(), executable->isArrowFunctionContext(), variablesUnderTDZ, privateNameEnvironment, executable); 126 } 127 128 UnlinkedEvalCodeBlock* generateUnlinkedCodeBlockForDirectEval(VM& vm, DirectEvalExecutable* executable, const SourceCode& source, JSParserStrictMode strictMode, JSParserScriptMode scriptMode, OptionSet<CodeGenerationMode> codeGenerationMode, ParserError& error, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ, const PrivateNameEnvironment* privateNameEnvironment) 129 { 130 return generateUnlinkedCodeBlock<UnlinkedEvalCodeBlock>(vm, executable, source, strictMode, scriptMode, codeGenerationMode, error, evalContextType, variablesUnderTDZ, privateNameEnvironment); 128 131 } 129 132 … … 249 252 // in the global lexical environment, which we always TDZ check accesses from. 250 253 ConstructAbility constructAbility = constructAbilityForParseMode(metadata->parseMode()); 251 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(vm, source, metadata, UnlinkedNormalFunction, constructAbility, JSParserScriptMode::Classic, nullptr, DerivedContextType::None, NeedsClassFieldInitializer::No);254 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(vm, source, metadata, UnlinkedNormalFunction, constructAbility, JSParserScriptMode::Classic, nullptr, WTF::nullopt, DerivedContextType::None, NeedsClassFieldInitializer::No, PrivateBrandRequirement::None); 252 255 253 256 if (!source.provider()->sourceURLDirective().isNull()) -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r269115 r272580 255 255 }; 256 256 257 UnlinkedEvalCodeBlock* generateUnlinkedCodeBlockForDirectEval(VM&, DirectEvalExecutable*, const SourceCode&, JSParserStrictMode, JSParserScriptMode, OptionSet<CodeGenerationMode>, ParserError&, EvalContextType, const TDZEnvironment* variablesUnderTDZ, const VariableEnvironment* parentScopePrivateNames);257 UnlinkedEvalCodeBlock* generateUnlinkedCodeBlockForDirectEval(VM&, DirectEvalExecutable*, const SourceCode&, JSParserStrictMode, JSParserScriptMode, OptionSet<CodeGenerationMode>, ParserError&, EvalContextType, const TDZEnvironment* variablesUnderTDZ, const PrivateNameEnvironment*); 258 258 UnlinkedProgramCodeBlock* recursivelyGenerateUnlinkedCodeBlockForProgram(VM&, const SourceCode&, JSParserStrictMode, JSParserScriptMode, OptionSet<CodeGenerationMode>, ParserError&, EvalContextType); 259 259 UnlinkedModuleProgramCodeBlock* recursivelyGenerateUnlinkedCodeBlockForModuleProgram(VM&, const SourceCode&, JSParserStrictMode, JSParserScriptMode, OptionSet<CodeGenerationMode>, ParserError&, EvalContextType); -
trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.cpp
r269115 r272580 35 35 namespace JSC { 36 36 37 DirectEvalExecutable* DirectEvalExecutable::create(JSGlobalObject* globalObject, const SourceCode& source, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ, const VariableEnvironment* privateNames, ECMAMode ecmaMode)37 DirectEvalExecutable* DirectEvalExecutable::create(JSGlobalObject* globalObject, const SourceCode& source, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, const TDZEnvironment* variablesUnderTDZ, const PrivateNameEnvironment* privateNameEnvironment, ECMAMode ecmaMode) 38 38 { 39 39 VM& vm = globalObject->vm(); … … 45 45 } 46 46 47 auto* executable = new (NotNull, allocateCell<DirectEvalExecutable>(vm.heap)) DirectEvalExecutable(globalObject, source, ecmaMode.isStrict(), derivedContextType, needsClassFieldInitializer, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType);47 auto* executable = new (NotNull, allocateCell<DirectEvalExecutable>(vm.heap)) DirectEvalExecutable(globalObject, source, ecmaMode.isStrict(), derivedContextType, needsClassFieldInitializer, privateBrandRequirement, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType); 48 48 executable->finishCreation(vm); 49 49 … … 53 53 54 54 // We don't bother with CodeCache here because direct eval uses a specialized DirectEvalCodeCache. 55 UnlinkedEvalCodeBlock* unlinkedEvalCode = generateUnlinkedCodeBlockForDirectEval(vm, executable, executable->source(), strictMode, JSParserScriptMode::Classic, codeGenerationMode, error, evalContextType, variablesUnderTDZ, privateName s);55 UnlinkedEvalCodeBlock* unlinkedEvalCode = generateUnlinkedCodeBlockForDirectEval(vm, executable, executable->source(), strictMode, JSParserScriptMode::Classic, codeGenerationMode, error, evalContextType, variablesUnderTDZ, privateNameEnvironment); 56 56 57 57 if (globalObject->hasDebugger()) … … 68 68 } 69 69 70 DirectEvalExecutable::DirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType)71 : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, needsClassFieldInitializer )70 DirectEvalExecutable::DirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType) 71 : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, needsClassFieldInitializer, privateBrandRequirement) 72 72 { 73 ASSERT( needsClassFieldInitializer == NeedsClassFieldInitializer::No|| derivedContextType == DerivedContextType::DerivedConstructorContext);73 ASSERT((needsClassFieldInitializer == NeedsClassFieldInitializer::No && privateBrandRequirement == PrivateBrandRequirement::None) || derivedContextType == DerivedContextType::DerivedConstructorContext); 74 74 } 75 75 -
trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.h
r269115 r272580 32 32 class DirectEvalExecutable final : public EvalExecutable { 33 33 public: 34 static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, const TDZEnvironment* parentScopeTDZVariables, const VariableEnvironment* privateNames, ECMAMode);34 static DirectEvalExecutable* create(JSGlobalObject*, const SourceCode&, DerivedContextType, NeedsClassFieldInitializer, PrivateBrandRequirement, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, const TDZEnvironment* parentScopeTDZVariables, const PrivateNameEnvironment*, ECMAMode); 35 35 private: 36 DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType);36 DirectEvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, NeedsClassFieldInitializer, PrivateBrandRequirement, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType); 37 37 }; 38 38 -
trunk/Source/JavaScriptCore/runtime/EvalExecutable.cpp
r261895 r272580 33 33 const ClassInfo EvalExecutable::s_info = { "EvalExecutable", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(EvalExecutable) }; 34 34 35 EvalExecutable::EvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, NeedsClassFieldInitializer needsClassFieldInitializer )35 EvalExecutable::EvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, bool inStrictContext, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType evalContextType, NeedsClassFieldInitializer needsClassFieldInitializer, PrivateBrandRequirement privateBrandRequirement) 36 36 : Base(globalObject->vm().evalExecutableStructure.get(), globalObject->vm(), source, inStrictContext, derivedContextType, isArrowFunctionContext, isInsideOrdinaryFunction, evalContextType, NoIntrinsic) 37 37 , m_needsClassFieldInitializer(static_cast<unsigned>(needsClassFieldInitializer)) 38 , m_privateBrandRequirement(static_cast<unsigned>(privateBrandRequirement)) 38 39 { 39 40 ASSERT(source.provider()->sourceType() == SourceProviderSourceType::Program); -
trunk/Source/JavaScriptCore/runtime/EvalExecutable.h
r259676 r272580 63 63 DECLARE_INFO; 64 64 65 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, false, ConstructorKind::None, JSParserScriptMode::Classic, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), needsClassFieldInitializer(), isArrowFunctionContext(), false, evalContextType()); }65 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, PrivateBrandRequirement::None, false, ConstructorKind::None, JSParserScriptMode::Classic, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), needsClassFieldInitializer(), isArrowFunctionContext(), false, evalContextType()); } 66 66 67 67 unsigned numVariables() { return m_unlinkedEvalCodeBlock->numVariables(); } … … 70 70 bool allowDirectEvalCache() const { return m_unlinkedEvalCodeBlock->allowDirectEvalCache(); } 71 71 NeedsClassFieldInitializer needsClassFieldInitializer() const { return static_cast<NeedsClassFieldInitializer>(m_needsClassFieldInitializer); } 72 PrivateBrandRequirement privateBrandRequirement() const { return static_cast<PrivateBrandRequirement>(m_privateBrandRequirement); } 72 73 TemplateObjectMap& ensureTemplateObjectMap(VM&); 73 74 … … 77 78 78 79 using Base::finishCreation; 79 EvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, NeedsClassFieldInitializer );80 EvalExecutable(JSGlobalObject*, const SourceCode&, bool inStrictContext, DerivedContextType, bool isArrowFunctionContext, bool isInsideOrdinaryFunction, EvalContextType, NeedsClassFieldInitializer, PrivateBrandRequirement); 80 81 81 82 static void visitChildren(JSCell*, SlotVisitor&); 82 83 83 84 unsigned m_needsClassFieldInitializer : 1; 85 unsigned m_privateBrandRequirement : 1; 84 86 85 87 WriteBarrier<ExecutableToCodeBlockEdge> m_evalCodeBlock; -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r262613 r272580 335 335 } 336 336 337 JSObject* createPrivateMethodAccessError(JSGlobalObject* globalObject) 338 { 339 return createTypeError(globalObject, makeString("Cannot access private method"_s), defaultSourceAppender, TypeNothing); 340 } 341 342 JSObject* createReinstallPrivateMethodError(JSGlobalObject* globalObject) 343 { 344 return createTypeError(globalObject, makeString("Cannot install same private methods on object more than once"_s), defaultSourceAppender, TypeNothing); 345 } 346 337 347 Exception* throwOutOfMemoryError(JSGlobalObject* globalObject, ThrowScope& scope) 338 348 { -
trunk/Source/JavaScriptCore/runtime/IndirectEvalExecutable.cpp
r261755 r272580 70 70 constexpr bool insideOrdinaryFunction = false; 71 71 IndirectEvalExecutable::IndirectEvalExecutable(JSGlobalObject* globalObject, const SourceCode& source, DerivedContextType derivedContextType, bool isArrowFunctionContext, EvalContextType evalContextType) 72 : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, insideOrdinaryFunction, evalContextType, NeedsClassFieldInitializer::No )72 : EvalExecutable(globalObject, source, inStrictContext, derivedContextType, isArrowFunctionContext, insideOrdinaryFunction, evalContextType, NeedsClassFieldInitializer::No, PrivateBrandRequirement::None) 73 73 { 74 74 } -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r271269 r272580 185 185 inline void setPrivateField(JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); 186 186 inline void definePrivateField(JSGlobalObject*, PropertyName, JSValue, PutPropertySlot&); 187 inline bool checkPrivateBrand(JSGlobalObject*, JSValue brand); 188 inline void setPrivateBrand(JSGlobalObject*, JSValue brand); 187 189 188 190 unsigned getArrayLength() const -
trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h
r271599 r272580 25 25 26 26 #include "AuxiliaryBarrierInlines.h" 27 #include "BrandedStructure.h" 27 28 #include "ButterflyInlines.h" 28 29 #include "Error.h" … … 579 580 JSObject* createInvalidPrivateNameError(JSGlobalObject*); 580 581 JSObject* createRedefinedPrivateNameError(JSGlobalObject*); 582 JSObject* createReinstallPrivateMethodError(JSGlobalObject*); 583 JSObject* createPrivateMethodAccessError(JSGlobalObject*); 581 584 582 585 ALWAYS_INLINE bool JSObject::getPrivateFieldSlot(JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, PropertySlot& slot) … … 670 673 } 671 674 675 inline bool JSObject::checkPrivateBrand(JSGlobalObject* globalObject, JSValue brand) 676 { 677 ASSERT(brand.isSymbol()); 678 VM& vm = getVM(globalObject); 679 auto scope = DECLARE_THROW_SCOPE(vm); 680 681 Structure* structure = this->structure(vm); 682 if (!structure->isBrandedStructure() || !jsCast<BrandedStructure*>(structure)->checkBrand(asSymbol(brand))) { 683 throwException(globalObject, scope, createPrivateMethodAccessError(globalObject)); 684 RELEASE_AND_RETURN(scope, false); 685 } 686 EXCEPTION_ASSERT(!scope.exception()); 687 688 return true; 689 } 690 691 inline void JSObject::setPrivateBrand(JSGlobalObject* globalObject, JSValue brand) 692 { 693 ASSERT(brand.isSymbol()); 694 VM& vm = getVM(globalObject); 695 auto scope = DECLARE_THROW_SCOPE(vm); 696 697 Structure* structure = this->structure(vm); 698 if (structure->isBrandedStructure() && jsCast<BrandedStructure*>(structure)->checkBrand(asSymbol(brand))) { 699 throwException(globalObject, scope, createReinstallPrivateMethodError(globalObject)); 700 RELEASE_AND_RETURN(scope, void()); 701 } 702 EXCEPTION_ASSERT(!scope.exception()); 703 704 scope.release(); 705 706 DeferredStructureTransitionWatchpointFire deferredWatchpointFire(vm, structure); 707 708 Structure* newStructure = Structure::setBrandTransition(vm, structure, asSymbol(brand), &deferredWatchpointFire); 709 ASSERT(newStructure->isBrandedStructure()); 710 ASSERT(newStructure->outOfLineCapacity() || !this->structure(vm)->outOfLineCapacity()); 711 this->setStructure(vm, newStructure); 712 } 713 672 714 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSScope.cpp
r269115 r272580 322 322 } 323 323 324 void JSScope::collectClosureVariablesUnderTDZ(JSScope* scope, TDZEnvironment& result, VariableEnvironment& privateNames)324 void JSScope::collectClosureVariablesUnderTDZ(JSScope* scope, TDZEnvironment& result, PrivateNameEnvironment& privateNameEnvironment) 325 325 { 326 326 for (; scope; scope = scope->next()) { … … 341 341 342 342 if (symbolTable->hasPrivateNames()) { 343 for (auto name : symbolTable->privateNames()) 344 privateNames.usePrivateName(name); 343 auto privateNames = symbolTable->privateNames(); 344 for (auto end = privateNames.end(), iter = privateNames.begin(); iter != end; ++iter) 345 privateNameEnvironment.add(iter->key, iter->value); 345 346 } 346 347 } -
trunk/Source/JavaScriptCore/runtime/JSScope.h
r269115 r272580 28 28 #include "GetPutInfo.h" 29 29 #include "JSObject.h" 30 #include "VariableEnvironment.h" 30 31 31 32 namespace JSC { … … 33 34 class ScopeChainIterator; 34 35 class SymbolTable; 35 class VariableEnvironment;36 36 class WatchpointSet; 37 37 … … 63 63 static JSScope* constantScopeForCodeBlock(ResolveType, CodeBlock*); 64 64 65 static void collectClosureVariablesUnderTDZ(JSScope*, TDZEnvironment& result, VariableEnvironment& privateNames);65 static void collectClosureVariablesUnderTDZ(JSScope*, TDZEnvironment& result, PrivateNameEnvironment&); 66 66 67 67 static void visitChildren(JSCell*, SlotVisitor&); -
trunk/Source/JavaScriptCore/runtime/ModuleProgramExecutable.h
r259676 r272580 64 64 DECLARE_INFO; 65 65 66 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, false, ConstructorKind::None, JSParserScriptMode::Module, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, derivedContextType(), NeedsClassFieldInitializer::No, isArrowFunctionContext(), false, EvalContextType::None); }66 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, PrivateBrandRequirement::None, false, ConstructorKind::None, JSParserScriptMode::Module, SuperBinding::NotNeeded, SourceParseMode::ModuleEvaluateMode, derivedContextType(), NeedsClassFieldInitializer::No, isArrowFunctionContext(), false, EvalContextType::None); } 67 67 68 68 UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock() { return m_unlinkedModuleProgramCodeBlock.get(); } -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r272085 r272580 540 540 else if (Options::randomIntegrityAuditRate() > 1.0) 541 541 Options::randomIntegrityAuditRate() = 1.0; 542 543 if (Options::usePrivateMethods()) 544 Options::usePrivateClassFields() = true; 542 545 543 546 if (!Options::allowUnsupportedTiers()) { -
trunk/Source/JavaScriptCore/runtime/OptionsList.h
r272074 r272580 513 513 v(Bool, allowUnsupportedTiers, false, Normal, "If true, we will not disable DFG or FTL when an experimental feature is enabled.") \ 514 514 v(Bool, usePrivateClassFields, true, Normal, "If true, the parser will understand private data fields inside classes.") \ 515 v(Bool, usePrivateMethods, false, Normal, "If true, the parser will understand private methods inside classes.") \ 515 516 v(Bool, returnEarlyFromInfiniteLoopsForFuzzing, false, Normal, nullptr) \ 516 517 v(Size, earlyReturnFromInfiniteLoopsLimit, 1300000000, Normal, "When returnEarlyFromInfiniteLoopsForFuzzing is true, this determines the number of executions a loop can run for before just returning. This is helpful for the fuzzer so it doesn't get stuck in infinite loops.") \ … … 569 570 570 571 #define FOR_EACH_JSC_EXPERIMENTAL_OPTION(v) \ 571 v(usePrivateClassFields, (SupportsFTL | SupportsDFG), "https://bugs.webkit.org/show_bug.cgi?id=212781", "https://bugs.webkit.org/show_bug.cgi?id=212784") 572 v(usePrivateClassFields, (SupportsFTL | SupportsDFG), "https://bugs.webkit.org/show_bug.cgi?id=212781", "https://bugs.webkit.org/show_bug.cgi?id=212784") \ 573 v(usePrivateMethods, (SupportsFTL | SupportsDFG), "https://bugs.webkit.org/show_bug.cgi?id=194434", "https://bugs.webkit.org/show_bug.cgi?id=194434") 572 574 573 575 constexpr size_t countNumberOfJSCOptions() -
trunk/Source/JavaScriptCore/runtime/ProgramExecutable.h
r259676 r272580 72 72 DECLARE_INFO; 73 73 74 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, false, ConstructorKind::None, JSParserScriptMode::Classic, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), NeedsClassFieldInitializer::No, isArrowFunctionContext(), false, EvalContextType::None); }74 ExecutableInfo executableInfo() const { return ExecutableInfo(usesEval(), false, PrivateBrandRequirement::None, false, ConstructorKind::None, JSParserScriptMode::Classic, SuperBinding::NotNeeded, SourceParseMode::ProgramMode, derivedContextType(), NeedsClassFieldInitializer::No, isArrowFunctionContext(), false, EvalContextType::None); } 75 75 76 76 TemplateObjectMap& ensureTemplateObjectMap(VM&); -
trunk/Source/JavaScriptCore/runtime/Structure.cpp
r271269 r272580 28 28 #include "Structure.h" 29 29 30 #include "BrandedStructure.h" 30 31 #include "BuiltinNames.h" 31 32 #include "DumpContext.h" … … 425 426 for (size_t i = structures.size(); i--;) { 426 427 structure = structures[i]; 427 if (!structure->m_transitionPropertyName )428 if (!structure->m_transitionPropertyName || structure->transitionKind() == TransitionKind::SetBrand) 428 429 continue; 429 430 switch (structure->transitionKind()) { … … 1497 1498 } 1498 1499 1500 Structure* Structure::setBrandTransitionFromExistingStructureImpl(Structure* structure, UniquedStringImpl* brandID) 1501 { 1502 ASSERT(structure->isObject()); 1503 1504 if (structure->hasBeenDictionary()) 1505 return nullptr; 1506 1507 if (Structure* existingTransition = structure->m_transitionTable.get(brandID, 0, TransitionKind::SetBrand)) 1508 return existingTransition; 1509 1510 return nullptr; 1511 } 1512 1513 Structure* Structure::setBrandTransitionFromExistingStructureConcurrently(Structure* structure, UniquedStringImpl* brandID) 1514 { 1515 ConcurrentJSLocker locker(structure->m_lock); 1516 return setBrandTransitionFromExistingStructureImpl(structure, brandID); 1517 } 1518 1519 Structure* Structure::setBrandTransition(VM& vm, Structure* structure, Symbol* brand, DeferredStructureTransitionWatchpointFire* deferred) 1520 { 1521 Structure* existingTransition = setBrandTransitionFromExistingStructureImpl(structure, &brand->uid()); 1522 if (existingTransition) 1523 return existingTransition; 1524 1525 Structure* transition = BrandedStructure::create(vm, structure, &brand->uid(), deferred); 1526 transition->setTransitionKind(TransitionKind::SetBrand); 1527 1528 transition->m_cachedPrototypeChain.setMayBeNull(vm, transition, structure->m_cachedPrototypeChain.get()); 1529 transition->m_blob.setIndexingModeIncludingHistory(structure->indexingModeIncludingHistory()); 1530 transition->m_transitionPropertyName = &brand->uid(); 1531 transition->setTransitionPropertyAttributes(0); 1532 transition->setPropertyTable(vm, structure->takePropertyTableOrCloneIfPinned(vm)); 1533 transition->setMaxOffset(vm, structure->maxOffset()); 1534 checkOffset(transition->maxOffset(), transition->inlineCapacity()); 1535 1536 if (structure->isDictionary()) { 1537 PropertyTable* table = transition->ensurePropertyTable(vm); 1538 transition->pin(holdLock(transition->m_lock), vm, table); 1539 } else { 1540 auto locker = holdLock(structure->m_lock); 1541 structure->m_transitionTable.add(vm, transition); 1542 } 1543 1544 transition->checkOffsetConsistency(); 1545 return transition; 1546 } 1547 1499 1548 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/Structure.h
r271269 r272580 124 124 }; 125 125 126 class Structure final: public JSCell {126 class Structure : public JSCell { 127 127 static constexpr uint16_t shortInvalidOffset = std::numeric_limits<uint16_t>::max() - 1; 128 128 static constexpr uint16_t useRareDataFlag = std::numeric_limits<uint16_t>::max(); … … 147 147 JS_EXPORT_PRIVATE static bool isValidPrototype(JSValue); 148 148 149 private: 150 void finishCreation(VM& vm) 151 { 152 Base::finishCreation(vm); 153 ASSERT(m_prototype.get().isEmpty() || isValidPrototype(m_prototype.get())); 154 } 155 149 protected: 156 150 void finishCreation(VM& vm, const Structure* previous) 157 151 { … … 164 158 } 165 159 } 160 } 161 162 private: 163 void finishCreation(VM& vm) 164 { 165 Base::finishCreation(vm); 166 ASSERT(m_prototype.get().isEmpty() || isValidPrototype(m_prototype.get())); 166 167 } 167 168 … … 207 208 static Structure* nonPropertyTransition(VM&, Structure*, TransitionKind); 208 209 JS_EXPORT_PRIVATE static Structure* nonPropertyTransitionSlow(VM&, Structure*, TransitionKind); 210 static Structure* setBrandTransitionFromExistingStructureConcurrently(Structure*, UniquedStringImpl*); 211 static Structure* setBrandTransition(VM&, Structure*, Symbol* brand, DeferredStructureTransitionWatchpointFire* = nullptr); 209 212 210 213 JS_EXPORT_PRIVATE bool isSealed(VM&); … … 716 719 DEFINE_BITFIELD(bool, protectPropertyTableWhileTransitioning, ProtectPropertyTableWhileTransitioning, 1, 28); 717 720 DEFINE_BITFIELD(bool, hasUnderscoreProtoPropertyExcludingOriginalProto, HasUnderscoreProtoPropertyExcludingOriginalProto, 1, 29); 721 DEFINE_BITFIELD(bool, isBrandedStructure, IsBrandedStructure, 1, 30); 718 722 719 723 static_assert(s_bitWidthOfTransitionPropertyAttributes <= sizeof(TransitionPropertyAttributes) * 8); 720 724 static_assert(s_bitWidthOfTransitionKind <= sizeof(TransitionKind) * 8); 721 725 726 protected: 727 Structure(VM&, Structure*, DeferredStructureTransitionWatchpointFire*); 728 722 729 private: 723 730 friend class LLIntOffsetsExtractor; … … 725 732 JS_EXPORT_PRIVATE Structure(VM&, JSGlobalObject*, JSValue prototype, const TypeInfo&, const ClassInfo*, IndexingType, unsigned inlineCapacity); 726 733 Structure(VM&); 727 Structure(VM&, Structure*, DeferredStructureTransitionWatchpointFire*);728 734 729 735 static Structure* create(VM&, Structure*, DeferredStructureTransitionWatchpointFire* = nullptr); … … 731 737 static Structure* addPropertyTransitionToExistingStructureImpl(Structure*, UniquedStringImpl* uid, unsigned attributes, PropertyOffset&); 732 738 static Structure* removePropertyTransitionFromExistingStructureImpl(Structure*, PropertyName, unsigned attributes, PropertyOffset&); 739 static Structure* setBrandTransitionFromExistingStructureImpl(Structure*, UniquedStringImpl*); 733 740 734 741 // This will return the structure that has a usable property table, that property table, -
trunk/Source/JavaScriptCore/runtime/StructureInlines.h
r272430 r272580 26 26 #pragma once 27 27 28 #include "BrandedStructure.h" 28 29 #include "JSArrayBufferView.h" 29 30 #include "JSCJSValueInlines.h" … … 62 63 { 63 64 ASSERT(vm.structureStructure); 64 Structure* newStructure = new (NotNull, allocateCell<Structure>(vm.heap)) Structure(vm, previous, deferred); 65 Structure* newStructure; 66 if (previous->isBrandedStructure()) 67 newStructure = new (NotNull, allocateCell<BrandedStructure>(vm.heap)) BrandedStructure(vm, jsCast<BrandedStructure*>(previous), deferred); 68 else 69 newStructure = new (NotNull, allocateCell<Structure>(vm.heap)) Structure(vm, previous, deferred); 70 65 71 newStructure->finishCreation(vm, previous); 66 72 return newStructure; … … 182 188 break; 183 189 case TransitionKind::PropertyDeletion: 190 case TransitionKind::SetBrand: 184 191 continue; 185 192 default: -
trunk/Source/JavaScriptCore/runtime/StructureTransitionTable.h
r265640 r272580 56 56 PreventExtensions, 57 57 Seal, 58 Freeze 58 Freeze, 59 60 // Support for transitions related with private brand 61 SetBrand 59 62 }; 60 63 -
trunk/Source/JavaScriptCore/runtime/SymbolTable.cpp
r262613 r272580 185 185 { 186 186 for (auto name : m_rareData->m_privateNames) 187 result->m_rareData->m_privateNames.add(name );187 result->m_rareData->m_privateNames.add(name.key, name.value); 188 188 } 189 189 } -
trunk/Source/JavaScriptCore/runtime/SymbolTable.h
r263117 r272580 36 36 #include "TypeLocation.h" 37 37 #include "VarOffset.h" 38 #include "VariableEnvironment.h" 38 39 #include "Watchpoint.h" 39 40 #include <memory> … … 451 452 typedef HashMap<VarOffset, RefPtr<UniquedStringImpl>> OffsetToVariableMap; 452 453 typedef Vector<SymbolTableEntry*> LocalToEntryVec; 453 typedef HashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> PrivateNameSet; 454 typedef WTF::IteratorRange<typename PrivateNameSet::iterator> PrivateNameIteratorRange; 454 typedef WTF::IteratorRange<typename PrivateNameEnvironment::iterator> PrivateNameIteratorRange; 455 455 456 456 template<typename CellType, SubspaceAccess> … … 606 606 } 607 607 608 void addPrivateName( UniquedStringImpl* key)608 void addPrivateName(const RefPtr<UniquedStringImpl>& key, PrivateNameEntry value) 609 609 { 610 610 ASSERT(key && !key->isSymbol()); … … 612 612 m_rareData = WTF::makeUnique<SymbolTableRareData>(); 613 613 614 ASSERT( !m_rareData->m_privateNames.contains(key));615 m_rareData->m_privateNames.add(key );614 ASSERT(m_rareData->m_privateNames.find(key) == m_rareData->m_privateNames.end()); 615 m_rareData->m_privateNames.add(key, value); 616 616 } 617 617 … … 757 757 UniqueTypeSetMap m_uniqueTypeSetMap; 758 758 WriteBarrier<CodeBlock> m_codeBlock; 759 PrivateName Set m_privateNames;759 PrivateNameEnvironment m_privateNames; 760 760 }; 761 761 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r272170 r272580 34 34 #include "BigIntObject.h" 35 35 #include "BooleanObject.h" 36 #include "BrandedStructure.h" 36 37 #include "BuiltinExecutables.h" 37 38 #include "BytecodeIntrinsicRegistry.h" … … 370 371 , structureRareDataSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), StructureRareData) // Hash:0xaca4e62d 371 372 , structureSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), Structure) // Hash:0x1f1bcdca 373 , brandedStructureSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), BrandedStructure) 372 374 , symbolTableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), SymbolTable) // Hash:0xc5215afd 373 375 , executableToCodeBlockEdgesWithConstraints(executableToCodeBlockEdgeSpace) -
trunk/Source/JavaScriptCore/runtime/VM.h
r272170 r272580 466 466 IsoSubspace structureRareDataSpace; 467 467 IsoSubspace structureSpace; 468 IsoSubspace brandedStructureSpace; 468 469 IsoSubspace symbolTableSpace; 469 470
Note: See TracChangeset
for help on using the changeset viewer.