@@ -26,11 +26,6 @@ typedef struct {
26
26
uint32_t dk_version ;
27
27
} _PyAttrCache ;
28
28
29
- typedef struct {
30
- uint32_t module_keys_version ;
31
- uint32_t builtin_keys_version ;
32
- } _PyLoadGlobalCache ;
33
-
34
29
typedef struct {
35
30
/* Borrowed ref in LOAD_METHOD */
36
31
PyObject * obj ;
@@ -57,23 +52,35 @@ typedef union {
57
52
_PyEntryZero zero ;
58
53
_PyAdaptiveEntry adaptive ;
59
54
_PyAttrCache attr ;
60
- _PyLoadGlobalCache load_global ;
61
55
_PyObjectCache obj ;
62
56
_PyCallCache call ;
63
57
} SpecializedCacheEntry ;
64
58
65
59
#define INSTRUCTIONS_PER_ENTRY (sizeof(SpecializedCacheEntry)/sizeof(_Py_CODEUNIT))
66
60
61
+ /* Inline caches */
62
+
63
+ #define CACHE_ENTRIES (cache ) (sizeof(cache)/sizeof(_Py_CODEUNIT))
64
+
65
+ typedef struct {
66
+ _Py_CODEUNIT counter ;
67
+ _Py_CODEUNIT index ;
68
+ _Py_CODEUNIT module_keys_version ;
69
+ _Py_CODEUNIT _m1 ;
70
+ _Py_CODEUNIT builtin_keys_version ;
71
+ } _PyLoadGlobalCache ;
72
+
73
+ #define INLINE_CACHE_ENTRIES_LOAD_GLOBAL CACHE_ENTRIES(_PyLoadGlobalCache)
74
+
67
75
typedef struct {
68
76
_Py_CODEUNIT counter ;
69
77
} _PyBinaryOpCache ;
70
78
79
+ #define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
71
80
typedef struct {
72
81
_Py_CODEUNIT counter ;
73
82
} _PyUnpackSequenceCache ;
74
83
75
- #define INLINE_CACHE_ENTRIES_BINARY_OP \
76
- (sizeof(_PyBinaryOpCache) / sizeof(_Py_CODEUNIT))
77
84
78
85
#define INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE \
79
86
(sizeof(_PyUnpackSequenceCache) / sizeof(_Py_CODEUNIT))
@@ -307,7 +314,7 @@ cache_backoff(_PyAdaptiveEntry *entry) {
307
314
308
315
extern int _Py_Specialize_LoadAttr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache );
309
316
extern int _Py_Specialize_StoreAttr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache );
310
- extern int _Py_Specialize_LoadGlobal (PyObject * globals , PyObject * builtins , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache );
317
+ extern int _Py_Specialize_LoadGlobal (PyObject * globals , PyObject * builtins , _Py_CODEUNIT * instr , PyObject * name );
311
318
extern int _Py_Specialize_LoadMethod (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache );
312
319
extern int _Py_Specialize_BinarySubscr (PyObject * sub , PyObject * container , _Py_CODEUNIT * instr , SpecializedCacheEntry * cache );
313
320
extern int _Py_Specialize_StoreSubscr (PyObject * container , PyObject * sub , _Py_CODEUNIT * instr );
@@ -388,6 +395,38 @@ extern PyObject* _Py_GetSpecializationStats(void);
388
395
#define OBJECT_STAT_INC (name ) ((void)0)
389
396
#endif
390
397
398
+ // Cache values are only valid in memory, so use native endianness.
399
+ #ifdef WORDS_BIGENDIAN
400
+
401
+ static inline void
402
+ write32 (uint16_t * p , uint32_t val )
403
+ {
404
+ p [0 ] = val >> 16 ;
405
+ p [1 ] = (uint16_t )val ;
406
+ }
407
+
408
+ static inline uint32_t
409
+ read32 (uint16_t * p )
410
+ {
411
+ return (p [0 ] << 16 ) | p [1 ];
412
+ }
413
+
414
+ #else
415
+
416
+ static inline void
417
+ write32 (uint16_t * p , uint32_t val )
418
+ {
419
+ p [0 ] = (uint16_t )val ;
420
+ p [1 ] = val >> 16 ;
421
+ }
422
+
423
+ static inline uint32_t
424
+ read32 (uint16_t * p )
425
+ {
426
+ return p [0 ] | (p [1 ] << 16 );
427
+ }
428
+
429
+ #endif
391
430
392
431
#ifdef __cplusplus
393
432
}
0 commit comments