Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba2a612

Browse files
committed
use tagged ints for indexes. Work in progress
1 parent9ca5b0e commitba2a612

15 files changed

+422
-385
lines changed

‎Include/internal/pycore_ceval.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ PyAPI_FUNC(_PyStackRef) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyS
362362
#endif
363363
#endif
364364

365+
_PyStackRef_PyForIter_NextWithIndex(PyObject*seq,_PyStackRefindex);
366+
365367
#ifdef__cplusplus
366368
}
367369
#endif

‎Include/internal/pycore_code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ extern void _Py_Specialize_CompareOp(_PyStackRef lhs, _PyStackRef rhs,
311311
_Py_CODEUNIT*instr,intoparg);
312312
externvoid_Py_Specialize_UnpackSequence(_PyStackRefseq,_Py_CODEUNIT*instr,
313313
intoparg);
314-
externvoid_Py_Specialize_ForIter(_PyStackRefiter,_Py_CODEUNIT*instr,intoparg);
314+
externvoid_Py_Specialize_ForIter(_PyStackRefiter,_PyStackRefnull_or_index,_Py_CODEUNIT*instr,intoparg);
315315
externvoid_Py_Specialize_Send(_PyStackRefreceiver,_Py_CODEUNIT*instr);
316316
externvoid_Py_Specialize_ToBool(_PyStackRefvalue,_Py_CODEUNIT*instr);
317317
externvoid_Py_Specialize_ContainsOp(_PyStackRefvalue,_Py_CODEUNIT*instr);

‎Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Include/internal/pycore_stackref.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ extern intptr_t PyStackRef_UntagInt(_PyStackRef ref);
231231

232232
extern_PyStackRefPyStackRef_TagInt(intptr_ti);
233233

234+
extern_PyStackRefPyStackRef_IncrementTaggedInt(_PyStackRefref);
235+
234236
externbool
235237
PyStackRef_IsNullOrInt(_PyStackRefref);
236238

@@ -255,7 +257,16 @@ static inline intptr_t
255257
PyStackRef_UntagInt(_PyStackRefi)
256258
{
257259
assert((i.bits&Py_INT_TAG)==Py_INT_TAG);
258-
returnPy_ARITHMETIC_RIGHT_SHIFT(intptr_t,i.bits,2);
260+
intptr_tval= (intptr_t)i.bits;
261+
returnPy_ARITHMETIC_RIGHT_SHIFT(intptr_t,val,2);
262+
}
263+
264+
265+
staticinline_PyStackRef
266+
PyStackRef_IncrementTaggedInt(_PyStackRefref)
267+
{
268+
assert(ref.bits!= (uintptr_t)-1);// Overflow
269+
return (_PyStackRef){ .bits=ref.bits+4 };
259270
}
260271

261272

@@ -683,7 +694,13 @@ PyStackRef_XCLOSE(_PyStackRef ref)
683694

684695
#endif// !defined(Py_GIL_DISABLED) && defined(Py_STACKREF_DEBUG)
685696

686-
#definePyStackRef_TYPE(stackref) Py_TYPE(PyStackRef_AsPyObjectBorrow(stackref))
697+
staticinlinePyTypeObject*
698+
PyStackRef_TYPE(_PyStackRefstackref) {
699+
if (PyStackRef_IsTaggedInt(stackref)) {
700+
return&PyLong_Type;
701+
}
702+
returnPy_TYPE(PyStackRef_AsPyObjectBorrow(stackref));
703+
}
687704

688705
// Converts a PyStackRef back to a PyObject *, converting the
689706
// stackref to a new reference.

‎Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp