summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-06-03 12:30:58 (GMT)
committerGitHub <noreply@github.com>2019-06-03 12:30:58 (GMT)
commit91234a16367b56ca03ee289f7c03a34d4cfec4c8 (patch)
tree81d13661e09df4712009641eaba30e4599f1b776 /Objects/dictobject.c
parent29ec4228106ed5f970d1c3666614f4a51bad192c (diff)
downloadcpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.zip
cpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.tar.gz
cpython-91234a16367b56ca03ee289f7c03a34d4cfec4c8.tar.bz2
bpo-26219: per opcode cache for LOAD_GLOBAL (GH-12884)
This patch implements per opcode cache mechanism, and use it in only LOAD_GLOBAL opcode. Based on Yury's opcache3.patch in bpo-26219.
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 2b04b0b..0cc1443 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1080,20 +1080,21 @@ insertdict(PyDictObject *mp, PyObject *key, Py_hash_t hash, PyObject *value)
return 0;
}
- if (_PyDict_HasSplitTable(mp)) {
- mp->ma_values[ix] = value;
- if (old_value == NULL) {
- /* pending state */
- assert(ix == mp->ma_used);
- mp->ma_used++;
+ if (old_value != value) {
+ if (_PyDict_HasSplitTable(mp)) {
+ mp->ma_values[ix] = value;
+ if (old_value == NULL) {
+ /* pending state */
+ assert(ix == mp->ma_used);
+ mp->ma_used++;
+ }
}
+ else {
+ assert(old_value != NULL);
+ DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
+ }
+ mp->ma_version_tag = DICT_NEXT_VERSION();
}
- else {
- assert(old_value != NULL);
- DK_ENTRIES(mp->ma_keys)[ix].me_value = value;
- }
-
- mp->ma_version_tag = DICT_NEXT_VERSION();
Py_XDECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
ASSERT_CONSISTENT(mp);
Py_DECREF(key);