Skip to content

Commit 16c8ed6

Browse files
committed
write_ptr
1 parent 988369d commit 16c8ed6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

Include/internal/pycore_code.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,7 @@ write_u64(uint16_t *p, uint64_t val)
439439
}
440440

441441
static inline void
442-
write_obj(uint16_t *p, PyObject *val)
443-
{
444-
memcpy(p, &val, sizeof(val));
445-
}
446-
447-
static inline void
448-
write_void(uint16_t *p, void *val)
442+
write_ptr(uint16_t *p, void *val)
449443
{
450444
memcpy(p, &val, sizeof(val));
451445
}

Python/specialize.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
11741174
assert(tp_version != 0);
11751175
write_u32(lm_cache->type_version, tp_version);
11761176
/* borrowed */
1177-
write_obj(lm_cache->descr, fget);
1177+
write_ptr(lm_cache->descr, fget);
11781178
specialize(instr, LOAD_ATTR_PROPERTY);
11791179
return 0;
11801180
}
@@ -1254,7 +1254,7 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
12541254
#endif
12551255
write_u32(lm_cache->keys_version, version);
12561256
/* borrowed */
1257-
write_obj(lm_cache->descr, descr);
1257+
write_ptr(lm_cache->descr, descr);
12581258
write_u32(lm_cache->type_version, tp_version);
12591259
specialize(instr, LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN);
12601260
return 0;
@@ -1534,7 +1534,7 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
15341534
}
15351535
#endif
15361536
write_u32(cache->type_version, tp_version);
1537-
write_obj(cache->descr, descr);
1537+
write_ptr(cache->descr, descr);
15381538
if (metaclass_check) {
15391539
write_u32(cache->keys_version, meta_version);
15401540
specialize(instr, LOAD_ATTR_CLASS_WITH_METACLASS_CHECK);
@@ -1642,7 +1642,7 @@ specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
16421642
* working since Python 2.6 and it's battle-tested.
16431643
*/
16441644
write_u32(cache->type_version, tp_version);
1645-
write_obj(cache->descr, descr);
1645+
write_ptr(cache->descr, descr);
16461646
return 1;
16471647
}
16481648

@@ -2509,7 +2509,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
25092509

25102510
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(instr + 1);
25112511
if (instr->op.code == BINARY_OP_EXTEND) {
2512-
write_void(cache->external_cache, NULL);
2512+
write_ptr(cache->external_cache, NULL);
25132513
}
25142514

25152515
switch (oparg) {
@@ -2570,7 +2570,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
25702570
_PyBinaryOpSpecializationDescr *descr;
25712571
if (binary_op_extended_specialization(lhs, rhs, oparg, &descr)) {
25722572
specialize(instr, BINARY_OP_EXTEND);
2573-
write_void(cache->external_cache, (void*)descr);
2573+
write_ptr(cache->external_cache, (void*)descr);
25742574
return;
25752575
}
25762576

0 commit comments

Comments
 (0)