Changeset 275547 in webkit
- Timestamp:
- Apr 6, 2021 1:43:00 PM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r275543 r275547 1 2021-04-06 Simon Fraser <simon.fraser@apple.com> 2 3 Shrink some IndexedDB-related classes 4 https://bugs.webkit.org/show_bug.cgi?id=224221 5 6 Reviewed by Geoffrey Garen. 7 8 Shrink some enum classes, and re-order data members to optimize packing in 9 IDBRequest and IDBKeyRangeData. 10 11 A couple of data members of IDBRequest were made private with protected setters. 12 13 This shrinks IDBRequest from 496 bytes to 448 bytes, and IDBKeyRangeData from 96 14 to 72 bytes on x86_64. 15 16 * Modules/indexeddb/IDBKeyData.h: 17 * Modules/indexeddb/IDBKeyRangeData.cpp: 18 (WebCore::IDBKeyRangeData::IDBKeyRangeData): 19 * Modules/indexeddb/IDBKeyRangeData.h: 20 (WebCore::IDBKeyRangeData::IDBKeyRangeData): 21 * Modules/indexeddb/IDBObjectStore.h: 22 * Modules/indexeddb/IDBOpenDBRequest.cpp: 23 (WebCore::IDBOpenDBRequest::IDBOpenDBRequest): 24 (WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish): 25 (WebCore::IDBOpenDBRequest::onSuccess): 26 (WebCore::IDBOpenDBRequest::onUpgradeNeeded): 27 (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess): 28 * Modules/indexeddb/IDBRequest.cpp: 29 (WebCore::IDBRequest::IDBRequest): 30 * Modules/indexeddb/IDBRequest.h: 31 (WebCore::IDBRequest::setReadyState): 32 (WebCore::IDBRequest::setShouldExposeTransactionToDOM): 33 * Modules/indexeddb/IndexedDB.h: 34 * Modules/indexeddb/client/IDBConnectionToServerDelegate.h: 35 * Modules/indexeddb/server/MemoryIndex.h: 36 * Modules/indexeddb/server/MemoryObjectStore.h: 37 * Modules/indexeddb/shared/IDBCursorInfo.h: 38 * Modules/indexeddb/shared/IDBGetAllRecordsData.h: 39 1 40 2021-04-06 Ryosuke Niwa <rniwa@webkit.org> 2 41 -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.h
r275151 r275547 192 192 193 193 IndexedDB::KeyType m_type; 194 Variant<Vector<IDBKeyData>, String, double, ThreadSafeDataBuffer> m_value;195 196 194 bool m_isNull { false }; 197 195 bool m_isDeletedValue { false }; 196 197 Variant<Vector<IDBKeyData>, String, double, ThreadSafeDataBuffer> m_value; 198 198 }; 199 199 -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp
r275151 r275547 32 32 33 33 IDBKeyRangeData::IDBKeyRangeData(IDBKey* key) 34 : isNull(!key) 35 , lowerKey(key) 34 : lowerKey(key) 36 35 , upperKey(key) 37 , lowerOpen(false) 38 , upperOpen(false) 36 , isNull(!key) 39 37 { 40 38 } 41 39 42 40 IDBKeyRangeData::IDBKeyRangeData(const IDBKeyData& keyData) 43 : isNull(keyData.isNull()) 44 , lowerKey(keyData) 41 : lowerKey(keyData) 45 42 , upperKey(keyData) 46 , lowerOpen(false) 47 , upperOpen(false) 43 , isNull(keyData.isNull()) 48 44 { 49 45 } -
trunk/Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h
r275151 r275547 36 36 IDBKeyRangeData() 37 37 : isNull(true) 38 , lowerOpen(false)39 , upperOpen(false)40 38 { 41 39 } … … 55 53 IDBKeyRangeData(IDBKeyRange* keyRange) 56 54 : isNull(!keyRange) 57 , lowerOpen(false)58 , upperOpen(false)59 55 { 60 56 if (isNull) … … 78 74 template<class Decoder> static WARN_UNUSED_RETURN bool decode(Decoder&, IDBKeyRangeData&); 79 75 80 bool isNull;81 82 76 IDBKeyData lowerKey; 83 77 IDBKeyData upperKey; 84 78 85 bool lowerOpen; 86 bool upperOpen; 79 bool lowerOpen { false }; 80 bool upperOpen { false }; 81 82 bool isNull; 87 83 88 84 #if !LOG_DISABLED -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h
r275151 r275547 51 51 52 52 namespace IndexedDB { 53 enum class ObjectStoreOverwriteMode ;53 enum class ObjectStoreOverwriteMode : uint8_t; 54 54 } 55 55 -
trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
r275151 r275547 56 56 57 57 IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType) 58 : IDBRequest(context, connectionProxy )58 : IDBRequest(context, connectionProxy, requestType) 59 59 , m_databaseIdentifier(databaseIdentifier) 60 60 , m_version(version) 61 61 { 62 m_requestType = requestType;63 62 } 64 63 … … 82 81 // 3.3.7 "versionchange" transaction steps 83 82 // When the transaction is finished, after firing complete/abort on the transaction, immediately set request's transaction property to null. 84 m_shouldExposeTransactionToDOM = false;83 setShouldExposeTransactionToDOM(false); 85 84 } 86 85 … … 138 137 139 138 setResult(IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData)); 140 m_readyState = ReadyState::Done;139 setReadyState(ReadyState::Done); 141 140 142 141 enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, Event::CanBubble::No, Event::IsCancelable::No, *this)); … … 159 158 160 159 setResult(WTFMove(database)); 161 m_readyState = ReadyState::Done;160 setReadyState(ReadyState::Done); 162 161 m_transaction = WTFMove(transaction); 163 162 m_transaction->addRequest(*this); … … 174 173 LOG(IndexedDB, "IDBOpenDBRequest::onDeleteDatabaseSuccess() - current version is %" PRIu64, oldVersion); 175 174 176 m_readyState = ReadyState::Done;175 setReadyState(ReadyState::Done); 177 176 setResultToUndefined(); 178 177 -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r275151 r275547 82 82 } 83 83 84 IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy )84 IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, IndexedDB::RequestType requestType) 85 85 : IDBActiveDOMObject(&context) 86 86 , m_resourceIdentifier(connectionProxy) 87 , m_result(NullResultType::Undefined) 87 88 , m_connectionProxy(connectionProxy) 88 { 89 m_result = NullResultType::Undefined; 89 , m_requestType(requestType) 90 { 90 91 suspendIfNeeded(); 91 92 } … … 95 96 , m_transaction(&transaction) 96 97 , m_resourceIdentifier(transaction.connectionProxy()) 98 , m_result(NullResultType::Undefined) 97 99 , m_source(&objectStore) 98 100 , m_connectionProxy(transaction.database().connectionProxy()) 99 101 { 100 m_result = NullResultType::Undefined;101 102 suspendIfNeeded(); 102 103 } … … 106 107 , m_transaction(&transaction) 107 108 , m_resourceIdentifier(transaction.connectionProxy()) 109 , m_result(NullResultType::Undefined) 108 110 , m_pendingCursor(&cursor) 109 111 , m_connectionProxy(transaction.database().connectionProxy()) … … 115 117 ); 116 118 117 m_result = NullResultType::Undefined;118 119 cursor.setRequest(*this); 119 120 } … … 123 124 , m_transaction(&transaction) 124 125 , m_resourceIdentifier(transaction.connectionProxy()) 126 , m_result(NullResultType::Undefined) 125 127 , m_source(&index) 126 128 , m_connectionProxy(transaction.database().connectionProxy()) 127 129 { 128 m_result = NullResultType::Undefined;129 130 suspendIfNeeded(); 130 131 } … … 134 135 , m_transaction(&transaction) 135 136 , m_resourceIdentifier(transaction.connectionProxy()) 137 , m_result(NullResultType::Undefined) 136 138 , m_source(&objectStore) 139 , m_connectionProxy(transaction.database().connectionProxy()) 137 140 , m_requestedObjectStoreRecordType(type) 138 , m_connectionProxy(transaction.database().connectionProxy()) 139 { 140 m_result = NullResultType::Undefined; 141 { 141 142 suspendIfNeeded(); 142 143 } … … 145 146 : IDBRequest(context, index, transaction) 146 147 { 147 m_result = NullResultType::Undefined;148 148 m_requestedIndexRecordType = requestedRecordType; 149 149 } -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h
r275151 r275547 127 127 128 128 protected: 129 IDBRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy& );129 IDBRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, IndexedDB::RequestType); 130 130 131 131 void enqueueEvent(Ref<Event>&&); … … 133 133 134 134 void setResult(Ref<IDBDatabase>&&); 135 void setReadyState(ReadyState state) { m_readyState = state; } 136 137 void setShouldExposeTransactionToDOM(bool shouldExposeTransactionToDOM) { m_shouldExposeTransactionToDOM = shouldExposeTransactionToDOM; } 135 138 136 139 IDBClient::IDBConnectionProxy& connectionProxy() { return m_connectionProxy.get(); } 137 138 // FIXME: Protected data members aren't great for maintainability.139 // Consider adding protected helper functions and making these private.140 ReadyState m_readyState { ReadyState::Pending };141 RefPtr<IDBTransaction> m_transaction;142 bool m_shouldExposeTransactionToDOM { true };143 RefPtr<DOMException> m_domError;144 IndexedDB::RequestType m_requestType { IndexedDB::RequestType::Other };145 Event* m_openDatabaseSuccessEvent { nullptr };146 140 147 141 private: … … 172 166 void clearWrappers(); 173 167 168 protected: 169 // FIXME: Protected data members aren't great for maintainability. 170 // Consider adding protected helper functions and making these private. 171 RefPtr<IDBTransaction> m_transaction; 172 RefPtr<DOMException> m_domError; 173 Event* m_openDatabaseSuccessEvent { nullptr }; 174 175 private: 174 176 IDBCursor* resultCursor(); 175 177 … … 179 181 JSValueInWrappedObject m_resultWrapper; 180 182 JSValueInWrappedObject m_cursorWrapper; 183 184 uint64_t m_currentTransactionOperationID { 0 }; 185 181 186 Result m_result; 182 187 Optional<Source> m_source; 183 188 184 bool m_hasPendingActivity { true }; 189 RefPtr<IDBCursor> m_pendingCursor; 190 Ref<IDBClient::IDBConnectionProxy> m_connectionProxy; 191 192 ReadyState m_readyState { ReadyState::Pending }; 193 IndexedDB::RequestType m_requestType { IndexedDB::RequestType::Other }; 185 194 IndexedDB::ObjectStoreRecordType m_requestedObjectStoreRecordType { IndexedDB::ObjectStoreRecordType::ValueOnly }; 186 195 IndexedDB::IndexRecordType m_requestedIndexRecordType { IndexedDB::IndexRecordType::Key }; 187 196 188 RefPtr<IDBCursor> m_pendingCursor; 189 190 Ref<IDBClient::IDBConnectionProxy> m_connectionProxy; 191 197 bool m_shouldExposeTransactionToDOM { true }; 198 bool m_hasPendingActivity { true }; 192 199 bool m_dispatchingEvent { false }; 193 200 bool m_hasUncaughtException { false }; 194 195 uint64_t m_currentTransactionOperationID { 0 };196 201 }; 197 202 -
trunk/Source/WebCore/Modules/indexeddb/IndexedDB.h
r275151 r275547 33 33 namespace IndexedDB { 34 34 35 enum class TransactionState {35 enum class TransactionState : uint8_t { 36 36 Active, 37 37 Inactive, … … 41 41 }; 42 42 43 enum class CursorDirection {43 enum class CursorDirection : uint8_t { 44 44 Next, 45 45 Nextunique, … … 50 50 51 51 enum class CursorType : bool { 52 KeyAndValue = 0,53 KeyOnly = 1,52 KeyAndValue, 53 KeyOnly, 54 54 }; 55 55 const unsigned CursorTypeMaximum = 1; … … 60 60 }; 61 61 62 enum class VersionNullness {62 enum class VersionNullness : uint8_t { 63 63 Null, 64 64 NonNull, 65 65 }; 66 66 67 enum class ObjectStoreOverwriteMode {67 enum class ObjectStoreOverwriteMode : uint8_t { 68 68 Overwrite, 69 69 OverwriteForCursor, … … 76 76 }; 77 77 78 enum class ObjectStoreRecordType {78 enum class ObjectStoreRecordType : uint8_t { 79 79 ValueOnly, 80 80 KeyOnly, … … 93 93 }; 94 94 95 enum class RequestType {95 enum class RequestType : uint8_t { 96 96 Open, 97 97 Delete, … … 99 99 }; 100 100 101 enum class GetAllType {101 enum class GetAllType : uint8_t { 102 102 Keys, 103 103 Values, -
trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h
r275151 r275547 47 47 48 48 namespace IndexedDB { 49 enum class ObjectStoreOverwriteMode ;49 enum class ObjectStoreOverwriteMode : uint8_t; 50 50 enum class ConnectionClosedOnBehalfOfServer : bool; 51 51 } -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIndex.h
r275151 r275547 44 44 45 45 namespace IndexedDB { 46 enum class GetAllType ;46 enum class GetAllType : uint8_t; 47 47 enum class IndexRecordType : bool; 48 48 } -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h
r275151 r275547 50 50 51 51 namespace IndexedDB { 52 enum class GetAllType ;52 enum class GetAllType : uint8_t; 53 53 enum class IndexRecordType : bool; 54 54 } -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h
r275151 r275547 34 34 35 35 namespace IndexedDB { 36 enum class CursorDirection ;36 enum class CursorDirection : uint8_t; 37 37 enum class CursorSource : bool; 38 38 enum class CursorType : bool; -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBGetAllRecordsData.h
r275151 r275547 32 32 33 33 namespace IndexedDB { 34 enum class DataSource; 35 enum class GetAllType; 34 enum class GetAllType : uint8_t; 36 35 } 37 36
Note: See TracChangeset
for help on using the changeset viewer.