-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Proposal] Reduce the minimum size for packed arrays from 8 to 2 #4783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,7 +394,8 @@ struct _zend_array { | |
#define HT_INVALID_IDX ((uint32_t) -1) | ||
|
||
#define HT_MIN_MASK ((uint32_t) -2) | ||
#define HT_MIN_SIZE 8 | ||
#define HT_MIN_SIZE 2 | ||
#define HT_MIN_SIZE_UNPACKED 8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
#if SIZEOF_SIZE_T == 4 | ||
# define HT_MAX_SIZE 0x04000000 /* small enough to avoid overflow checks */ | ||
|
@@ -422,7 +423,7 @@ struct _zend_array { | |
HT_HASH_EX((ht)->arData, idx) | ||
|
||
#define HT_SIZE_TO_MASK(nTableSize) \ | ||
((uint32_t)(-((nTableSize) + (nTableSize)))) | ||
(uint32_t)(-(zend_hash_check_size((nTableSize) + (nTableSize)))) | ||
#define HT_HASH_SIZE(nTableMask) \ | ||
(((size_t)(uint32_t)-(int32_t)(nTableMask)) * sizeof(uint32_t)) | ||
#define HT_DATA_SIZE(nTableSize) \ | ||
|
@@ -439,7 +440,15 @@ struct _zend_array { | |
size_t size = HT_HASH_SIZE((ht)->nTableMask); \ | ||
__m128i xmm0 = _mm_setzero_si128(); \ | ||
xmm0 = _mm_cmpeq_epi8(xmm0, xmm0); \ | ||
ZEND_ASSERT(size >= 64 && ((size & 0x3f) == 0)); \ | ||
if (size < 64) { \ | ||
ZEND_ASSERT(size == 16 || size == 32); \ | ||
_mm_storeu_si128((__m128i*)p, xmm0); \ | ||
if (size >= 32) { \ | ||
_mm_storeu_si128((__m128i*)(p+16), xmm0); \ | ||
} \ | ||
break; \ | ||
} \ | ||
Comment on lines
+443
to
+450
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How this is related to packed array size? This code is for assoc/maps only. |
||
ZEND_ASSERT(((size & 0x3f) == 0)); \ | ||
do { \ | ||
_mm_storeu_si128((__m128i*)p, xmm0); \ | ||
_mm_storeu_si128((__m128i*)(p+16), xmm0); \ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HashTable may be in 3 states -
packed
,map
anduninitialized
.array_init()
creates HashTable inunitilaized
state and it may becomepacked
ormap
depending on the followingzend_hash_real_init_*
or update operations.array_init_assoc()
creates HashTable inunitilaized
state as well, despite of the name.