Changeset 245050 in webkit
- Timestamp:
- May 7, 2019 9:35:36 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r245047 r245050 1 2019-05-07 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] LLIntPrototypeLoadAdaptiveStructureWatchpoint does not require Bag<> 4 https://bugs.webkit.org/show_bug.cgi?id=197645 5 6 Reviewed by Saam Barati. 7 8 We are using HashMap<std::tuple<Structure*, const Instruction*>, Bag<LLIntPrototypeLoadAdaptiveStructureWatchpoint>> for LLIntPrototypeLoadAdaptiveStructureWatchpoint, 9 but this has several memory inefficiency. 10 11 1. Structure* and Instruction* are too large. We can just use StructureID and bytecodeOffset (unsigned). 12 2. While we are using Bag<>, we do not add a new LLIntPrototypeLoadAdaptiveStructureWatchpoint after constructing this Bag first. So we can 13 use Vector<LLIntPrototypeLoadAdaptiveStructureWatchpoint> instead. We ensure that new entry won't be added to this Vector by making Watchpoint 14 non-movable. 15 3. Instead of having OpGetById::Metadata&, we just hold `unsigned` bytecodeOffset, and get Metadata& from the owner CodeBlock when needed. 16 17 * bytecode/CodeBlock.cpp: 18 (JSC::CodeBlock::finalizeLLIntInlineCaches): 19 * bytecode/CodeBlock.h: 20 * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp: 21 (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint): 22 (JSC::LLIntPrototypeLoadAdaptiveStructureWatchpoint::fireInternal): 23 * bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h: 24 * bytecode/Watchpoint.h: 25 * llint/LLIntSlowPaths.cpp: 26 (JSC::LLInt::setupGetByIdPrototypeCache): 27 1 28 2019-05-07 Yusuke Suzuki <ysuzuki@apple.com> 2 29 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r245040 r245050 1303 1303 m_llintGetByIdWatchpointMap.removeIf([&] (const StructureWatchpointMap::KeyValuePairType& pair) -> bool { 1304 1304 auto clear = [&] () { 1305 const Instruction* instruction = std::get<1>(pair.key);1305 auto& instruction = instructions().at(std::get<1>(pair.key)); 1306 1306 OpcodeID opcode = instruction->opcodeID(); 1307 1307 if (opcode == op_get_by_id) { … … 1313 1313 }; 1314 1314 1315 if (!vm.heap.isMarked( std::get<0>(pair.key)))1315 if (!vm.heap.isMarked(vm.heap.structureIDTable().get(std::get<0>(pair.key)))) 1316 1316 return clear(); 1317 1317 1318 for (const LLIntPrototypeLoadAdaptiveStructureWatchpoint *watchpoint : pair.value) {1319 if (!watchpoint ->key().isStillLive(vm))1318 for (const LLIntPrototypeLoadAdaptiveStructureWatchpoint& watchpoint : pair.value) { 1319 if (!watchpoint.key().isStillLive(vm)) 1320 1320 return clear(); 1321 1321 } -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r245040 r245050 638 638 } 639 639 640 typedef HashMap<std::tuple<Structure *, const Instruction*>, Bag<LLIntPrototypeLoadAdaptiveStructureWatchpoint>> StructureWatchpointMap;640 typedef HashMap<std::tuple<StructureID, unsigned>, Vector<LLIntPrototypeLoadAdaptiveStructureWatchpoint>> StructureWatchpointMap; 641 641 StructureWatchpointMap& llintGetByIdWatchpointMap() { return m_llintGetByIdWatchpointMap; } 642 642 -
trunk/Source/JavaScriptCore/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp
r243560 r245050 33 33 namespace JSC { 34 34 35 LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock* owner, const ObjectPropertyCondition& key, OpGetById::Metadata& getByIdMetadata)35 LLIntPrototypeLoadAdaptiveStructureWatchpoint::LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock* owner, const ObjectPropertyCondition& key, unsigned bytecodeOffset) 36 36 : m_owner(owner) 37 37 , m_key(key) 38 , m_ getByIdMetadata(getByIdMetadata)38 , m_bytecodeOffset(bytecodeOffset) 39 39 { 40 40 RELEASE_ASSERT(key.watchingRequiresStructureTransitionWatchpoint()); … … 59 59 } 60 60 61 clearLLIntGetByIdCache(m_getByIdMetadata); 61 auto& instruction = m_owner->instructions().at(m_bytecodeOffset); 62 clearLLIntGetByIdCache(instruction->as<OpGetById>().metadata(m_owner)); 62 63 } 63 64 -
trunk/Source/JavaScriptCore/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h
r243560 r245050 34 34 class LLIntPrototypeLoadAdaptiveStructureWatchpoint final : public Watchpoint { 35 35 public: 36 LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock*, const ObjectPropertyCondition&, OpGetById::Metadata&);36 LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock*, const ObjectPropertyCondition&, unsigned bytecodeOffset); 37 37 38 38 void install(VM&); … … 48 48 CodeBlock* m_owner; 49 49 ObjectPropertyCondition m_key; 50 OpGetById::Metadata& m_getByIdMetadata;50 unsigned m_bytecodeOffset; 51 51 }; 52 52 -
trunk/Source/JavaScriptCore/bytecode/Watchpoint.h
r239879 r245050 29 29 #include <wtf/FastMalloc.h> 30 30 #include <wtf/Noncopyable.h> 31 #include <wtf/Nonmovable.h> 31 32 #include <wtf/PrintStream.h> 32 33 #include <wtf/ScopedLambda.h> … … 92 93 class Watchpoint : public BasicRawSentinelNode<Watchpoint> { 93 94 WTF_MAKE_NONCOPYABLE(Watchpoint); 95 WTF_MAKE_NONMOVABLE(Watchpoint); 94 96 WTF_MAKE_FAST_ALLOCATED; 95 97 public: -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r244811 r245050 720 720 return; 721 721 722 unsigned bytecodeOffset = codeBlock->bytecodeOffset(pc); 722 723 PropertyOffset offset = invalidOffset; 723 724 CodeBlock::StructureWatchpointMap& watchpointMap = codeBlock->llintGetByIdWatchpointMap(); 724 Bag<LLIntPrototypeLoadAdaptiveStructureWatchpoint> watchpoints; 725 Vector<LLIntPrototypeLoadAdaptiveStructureWatchpoint> watchpoints; 726 watchpoints.reserveInitialCapacity(conditions.size()); 725 727 for (ObjectPropertyCondition condition : conditions) { 726 728 if (!condition.isWatchable()) … … 728 730 if (condition.condition().kind() == PropertyCondition::Presence) 729 731 offset = condition.condition().offset(); 730 watchpoints.add(codeBlock, condition, metadata)->install(vm); 732 watchpoints.uncheckedConstructAndAppend(codeBlock, condition, bytecodeOffset); 733 watchpoints.last().install(vm); 731 734 } 732 735 733 736 ASSERT((offset == invalidOffset) == slot.isUnset()); 734 auto result = watchpointMap.add(std::make_tuple(structure , pc), WTFMove(watchpoints));737 auto result = watchpointMap.add(std::make_tuple(structure->id(), bytecodeOffset), WTFMove(watchpoints)); 735 738 ASSERT_UNUSED(result, result.isNewEntry); 736 739 -
trunk/Source/WTF/ChangeLog
r245039 r245050 1 2019-05-07 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] LLIntPrototypeLoadAdaptiveStructureWatchpoint does not require Bag<> 4 https://bugs.webkit.org/show_bug.cgi?id=197645 5 6 Reviewed by Saam Barati. 7 8 * WTF.xcodeproj/project.pbxproj: 9 * wtf/CMakeLists.txt: 10 * wtf/Nonmovable.h: Copied from Source/JavaScriptCore/bytecode/LLIntPrototypeLoadAdaptiveStructureWatchpoint.h. 11 * wtf/Vector.h: 12 (WTF::minCapacity>::uncheckedConstructAndAppend): 13 1 14 2019-05-07 Eric Carlson <eric.carlson@apple.com> 2 15 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r244652 r245050 670 670 E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; }; 671 671 E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; }; 672 E3E64F0B22813428001E55B4 /* Nonmovable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nonmovable.h; sourceTree = "<group>"; }; 672 673 E431CC4A21187ADB000C8A07 /* DispatchSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DispatchSPI.h; sourceTree = "<group>"; }; 673 674 E4A0AD371A96245500536DF6 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; }; … … 1040 1041 0F0D85B317234CB100338210 /* NoLock.h */, 1041 1042 A8A472D0151A825B004123FF /* Noncopyable.h */, 1043 E3E64F0B22813428001E55B4 /* Nonmovable.h */, 1042 1044 526AEC911F6B4E5C00695F5D /* NoTailCalls.h */, 1043 1045 7CEAE5AC1EA6E10F00DB6890 /* NotFound.h */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r244907 r245050 140 140 NoTailCalls.h 141 141 Noncopyable.h 142 Nonmovable.h 142 143 NotFound.h 143 144 NumberOfCores.h -
trunk/Source/WTF/wtf/Nonmovable.h
r245049 r245050 1 1 /* 2 * Copyright (C) 201 6 Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include "BytecodeStructs.h" 29 #include "ObjectPropertyCondition.h" 30 #include "Watchpoint.h" 28 #define WTF_MAKE_NONMOVABLE(ClassName) \ 29 private: \ 30 ClassName(ClassName&&) = delete; \ 31 ClassName& operator=(ClassName&&) = delete; \ 31 32 32 namespace JSC {33 34 class LLIntPrototypeLoadAdaptiveStructureWatchpoint final : public Watchpoint {35 public:36 LLIntPrototypeLoadAdaptiveStructureWatchpoint(CodeBlock*, const ObjectPropertyCondition&, OpGetById::Metadata&);37 38 void install(VM&);39 40 static void clearLLIntGetByIdCache(OpGetById::Metadata&);41 42 const ObjectPropertyCondition& key() const { return m_key; }43 44 protected:45 void fireInternal(VM&, const FireDetail&) override;46 47 private:48 CodeBlock* m_owner;49 ObjectPropertyCondition m_key;50 OpGetById::Metadata& m_getByIdMetadata;51 };52 53 } // namespace JSC -
trunk/Source/WTF/wtf/Vector.h
r238031 r245050 776 776 void uncheckedAppend(ValueType&& value) { uncheckedAppend<ValueType>(std::forward<ValueType>(value)); } 777 777 template<typename U> void uncheckedAppend(U&&); 778 template<typename... Args> void uncheckedConstructAndAppend(Args&&...); 778 779 779 780 template<typename U> void append(const U*, size_t); … … 1389 1390 1390 1391 new (NotNull, end()) T(std::forward<U>(value)); 1392 ++m_size; 1393 } 1394 1395 template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity> 1396 template<typename... Args> 1397 ALWAYS_INLINE void Vector<T, inlineCapacity, OverflowHandler, minCapacity>::uncheckedConstructAndAppend(Args&&... args) 1398 { 1399 ASSERT(size() < capacity()); 1400 1401 asanBufferSizeWillChangeTo(m_size + 1); 1402 1403 new (NotNull, end()) T(std::forward<Args>(args)...); 1391 1404 ++m_size; 1392 1405 }
Note: See TracChangeset
for help on using the changeset viewer.