Changeset 242015 in webkit
- Timestamp:
- Feb 24, 2019 6:17:35 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r242014 r242015 1 2019-02-24 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Lazily create sentinel Map and Set buckets 4 https://bugs.webkit.org/show_bug.cgi?id=194975 5 6 Reviewed by Saam Barati. 7 8 If VM::canUseJIT() returns false, we can lazily initialize sentinel Map and Set buckets. 9 This patch adds getters to VM which lazily allocate these buckets. We eagerly initialize 10 them if VM::canUseJIT() returns true since they can be touched from DFG and FTL. 11 12 * bytecode/BytecodeIntrinsicRegistry.cpp: 13 (JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry): 14 (JSC::BytecodeIntrinsicRegistry::sentinelMapBucketValue): 15 (JSC::BytecodeIntrinsicRegistry::sentinelSetBucketValue): 16 * bytecode/BytecodeIntrinsicRegistry.h: 17 * dfg/DFGByteCodeParser.cpp: 18 (JSC::DFG::ByteCodeParser::handleIntrinsicCall): 19 * dfg/DFGOperations.cpp: 20 * dfg/DFGSpeculativeJIT.cpp: 21 (JSC::DFG::SpeculativeJIT::compileGetMapBucketNext): 22 * dfg/DFGSpeculativeJIT64.cpp: 23 (JSC::DFG::SpeculativeJIT::compile): 24 * ftl/FTLLowerDFGToB3.cpp: 25 (JSC::FTL::DFG::LowerDFGToB3::compileGetMapBucket): 26 (JSC::FTL::DFG::LowerDFGToB3::compileGetMapBucketNext): 27 * runtime/MapConstructor.cpp: 28 (JSC::mapPrivateFuncMapBucketNext): 29 * runtime/SetConstructor.cpp: 30 (JSC::setPrivateFuncSetBucketNext): 31 * runtime/VM.cpp: 32 (JSC::VM::VM): 33 (JSC::VM::sentinelSetBucketSlow): 34 (JSC::VM::sentinelMapBucketSlow): 35 * runtime/VM.h: 36 (JSC::VM::sentinelSetBucket): 37 (JSC::VM::sentinelMapBucket): 38 1 39 2019-02-20 Darin Adler <darin@apple.com> 2 40 -
trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
r221110 r242015 70 70 m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled))); 71 71 m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected))); 72 m_sentinelMapBucket.set(m_vm, m_vm.sentinelMapBucket.get());73 m_sentinelSetBucket.set(m_vm, m_vm.sentinelSetBucket.get());74 72 m_GeneratorResumeModeNormal.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorResumeMode::NormalMode))); 75 73 m_GeneratorResumeModeThrow.set(m_vm, jsNumber(static_cast<int32_t>(JSGeneratorFunction::GeneratorResumeMode::ThrowMode))); … … 102 100 return m_##name.get(); \ 103 101 } 104 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_ EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS)102 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_SIMPLE_EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS) 105 103 #undef JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS 104 105 JSValue BytecodeIntrinsicRegistry::sentinelMapBucketValue(BytecodeGenerator& generator) 106 { 107 return generator.vm()->sentinelMapBucket(); 108 } 109 110 JSValue BytecodeIntrinsicRegistry::sentinelSetBucketValue(BytecodeGenerator& generator) 111 { 112 return generator.vm()->sentinelSetBucket(); 113 } 106 114 107 115 } // namespace JSC -
trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h
r239761 r242015 67 67 68 68 #define JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_EACH_NAME(macro) \ 69 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_SIMPLE_EACH_NAME(macro) \ 70 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_CUSTOM_EACH_NAME(macro) \ 71 72 #define JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_SIMPLE_EACH_NAME(macro) \ 69 73 macro(undefined) \ 70 74 macro(Infinity) \ … … 86 90 macro(promiseStateFulfilled) \ 87 91 macro(promiseStateRejected) \ 88 macro(sentinelMapBucket) \89 macro(sentinelSetBucket) \90 92 macro(GeneratorResumeModeNormal) \ 91 93 macro(GeneratorResumeModeThrow) \ … … 101 103 macro(AsyncGeneratorSuspendReasonAwait) \ 102 104 macro(AsyncGeneratorSuspendReasonNone) \ 105 106 #define JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_CUSTOM_EACH_NAME(macro) \ 107 macro(sentinelMapBucket) \ 108 macro(sentinelSetBucket) \ 103 109 104 110 class BytecodeIntrinsicRegistry { … … 121 127 122 128 #define JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS(name) Strong<Unknown> m_##name; 123 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_ EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS)129 JSC_COMMON_BYTECODE_INTRINSIC_CONSTANTS_SIMPLE_EACH_NAME(JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS) 124 130 #undef JSC_DECLARE_BYTECODE_INTRINSIC_CONSTANT_GENERATORS 125 131 }; -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r241968 r242015 2930 2930 JSCell* sentinel = nullptr; 2931 2931 if (intrinsic == JSMapHasIntrinsic) 2932 sentinel = m_vm->sentinelMapBucket .get();2932 sentinel = m_vm->sentinelMapBucket(); 2933 2933 else 2934 sentinel = m_vm->sentinelSetBucket .get();2934 sentinel = m_vm->sentinelSetBucket(); 2935 2935 2936 2936 FrozenValue* frozenPointer = m_graph.freeze(sentinel); -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r241493 r242015 2893 2893 JSMap::BucketType** bucket = jsCast<JSMap*>(map)->findBucket(exec, JSValue::decode(key), hash); 2894 2894 if (!bucket) 2895 return vm.sentinelMapBucket .get();2895 return vm.sentinelMapBucket(); 2896 2896 return *bucket; 2897 2897 } … … 2903 2903 JSSet::BucketType** bucket = jsCast<JSSet*>(map)->findBucket(exec, JSValue::decode(key), hash); 2904 2904 if (!bucket) 2905 return vm.sentinelSetBucket .get();2905 return vm.sentinelSetBucket(); 2906 2906 return *bucket; 2907 2907 } … … 2913 2913 auto* bucket = jsCast<JSSet*>(set)->addNormalized(exec, JSValue::decode(key), JSValue(), hash); 2914 2914 if (!bucket) 2915 return vm.sentinelSetBucket .get();2915 return vm.sentinelSetBucket(); 2916 2916 return bucket; 2917 2917 } … … 2923 2923 auto* bucket = jsCast<JSMap*>(map)->addNormalized(exec, JSValue::decode(key), JSValue::decode(value), hash); 2924 2924 if (!bucket) 2925 return vm.sentinelMapBucket .get();2925 return vm.sentinelMapBucket(); 2926 2926 return bucket; 2927 2927 } -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r241228 r242015 11793 11793 JSCell* sentinel = nullptr; 11794 11794 if (node->bucketOwnerType() == BucketOwnerType::Map) 11795 sentinel = m_jit.vm()->sentinelMapBucket .get();11795 sentinel = m_jit.vm()->sentinelMapBucket(); 11796 11796 else { 11797 11797 ASSERT(node->bucketOwnerType() == BucketOwnerType::Set); 11798 sentinel = m_jit.vm()->sentinelSetBucket .get();11798 sentinel = m_jit.vm()->sentinelSetBucket(); 11799 11799 } 11800 11800 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), sentinel), resultGPR); -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r241849 r242015 4218 4218 notPresentInTable.link(&m_jit); 4219 4219 if (node->child1().useKind() == MapObjectUse) 4220 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->sentinelMapBucket .get()), resultGPR);4220 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->sentinelMapBucket()), resultGPR); 4221 4221 else 4222 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->sentinelSetBucket .get()), resultGPR);4222 m_jit.move(TrustedImmPtr::weakPointer(m_jit.graph(), m_jit.vm()->sentinelSetBucket()), resultGPR); 4223 4223 done.link(&m_jit); 4224 4224 cellResult(resultGPR, node); -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r241849 r242015 9745 9745 ValueFromBlock notPresentResult; 9746 9746 if (m_node->child1().useKind() == MapObjectUse) 9747 notPresentResult = m_out.anchor(weakPointer(vm().sentinelMapBucket .get()));9747 notPresentResult = m_out.anchor(weakPointer(vm().sentinelMapBucket())); 9748 9748 else if (m_node->child1().useKind() == SetObjectUse) 9749 notPresentResult = m_out.anchor(weakPointer(vm().sentinelSetBucket .get()));9749 notPresentResult = m_out.anchor(weakPointer(vm().sentinelSetBucket())); 9750 9750 else 9751 9751 RELEASE_ASSERT_NOT_REACHED(); … … 9793 9793 ValueFromBlock noBucketResult; 9794 9794 if (m_node->bucketOwnerType() == BucketOwnerType::Map) 9795 noBucketResult = m_out.anchor(weakPointer(vm().sentinelMapBucket .get()));9795 noBucketResult = m_out.anchor(weakPointer(vm().sentinelMapBucket())); 9796 9796 else { 9797 9797 ASSERT(m_node->bucketOwnerType() == BucketOwnerType::Set); 9798 noBucketResult = m_out.anchor(weakPointer(vm().sentinelSetBucket .get()));9798 noBucketResult = m_out.anchor(weakPointer(vm().sentinelSetBucket())); 9799 9799 } 9800 9800 m_out.jump(continuation); -
trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp
r236697 r242015 137 137 bucket = bucket->next(); 138 138 } 139 return JSValue::encode(exec->vm().sentinelMapBucket .get());139 return JSValue::encode(exec->vm().sentinelMapBucket()); 140 140 } 141 141 -
trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp
r236697 r242015 123 123 bucket = bucket->next(); 124 124 } 125 return JSValue::encode(exec->vm().sentinelSetBucket .get());125 return JSValue::encode(exec->vm().sentinelSetBucket()); 126 126 } 127 127 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r241955 r242015 402 402 executableToCodeBlockEdgeStructure.set(*this, ExecutableToCodeBlockEdge::createStructure(*this, nullptr, jsNull())); 403 403 404 sentinelSetBucket.set(*this, JSSet::BucketType::createSentinel(*this)); 405 sentinelMapBucket.set(*this, JSMap::BucketType::createSentinel(*this)); 404 // Eagerly initialize constant cells since the concurrent compiler can access them. 405 if (canUseJIT()) { 406 sentinelMapBucket(); 407 sentinelSetBucket(); 408 } 406 409 407 410 Thread::current().setCurrentAtomicStringTable(existingEntryAtomicStringTable); … … 1285 1288 #undef DYNAMIC_SPACE_AND_SET_DEFINE_MEMBER_SLOW 1286 1289 1290 1291 JSCell* VM::sentinelSetBucketSlow() 1292 { 1293 ASSERT(!m_sentinelSetBucket); 1294 auto* sentinel = JSSet::BucketType::createSentinel(*this); 1295 m_sentinelSetBucket.set(*this, sentinel); 1296 return sentinel; 1297 } 1298 1299 JSCell* VM::sentinelMapBucketSlow() 1300 { 1301 ASSERT(!m_sentinelMapBucket); 1302 auto* sentinel = JSMap::BucketType::createSentinel(*this); 1303 m_sentinelMapBucket.set(*this, sentinel); 1304 return sentinel; 1305 } 1306 1287 1307 JSGlobalObject* VM::vmEntryGlobalObject(const CallFrame* callFrame) const 1288 1308 { -
trunk/Source/JavaScriptCore/runtime/VM.h
r241582 r242015 540 540 541 541 Strong<JSCell> emptyPropertyNameEnumerator; 542 Strong<JSCell> sentinelSetBucket; 543 Strong<JSCell> sentinelMapBucket; 542 543 Strong<JSCell> m_sentinelSetBucket; 544 Strong<JSCell> m_sentinelMapBucket; 544 545 545 546 std::unique_ptr<PromiseDeferredTimer> promiseDeferredTimer; … … 563 564 WTF::SymbolRegistry& symbolRegistry() { return m_symbolRegistry; } 564 565 566 JSCell* sentinelSetBucket() 567 { 568 if (LIKELY(m_sentinelSetBucket)) 569 return m_sentinelSetBucket.get(); 570 return sentinelSetBucketSlow(); 571 } 572 573 JSCell* sentinelMapBucket() 574 { 575 if (LIKELY(m_sentinelMapBucket)) 576 return m_sentinelMapBucket.get(); 577 return sentinelMapBucketSlow(); 578 } 579 565 580 WeakGCMap<SymbolImpl*, Symbol, PtrHash<SymbolImpl*>> symbolImplToSymbolMap; 566 581 … … 890 905 static VM*& sharedInstanceInternal(); 891 906 void createNativeThunk(); 907 908 JSCell* sentinelSetBucketSlow(); 909 JSCell* sentinelMapBucketSlow(); 892 910 893 911 void updateStackLimits();
Note: See TracChangeset
for help on using the changeset viewer.