/* Bloom filter with m = 256
* https://en.wikipedia.org/wiki/Bloom_filter */
-#define BLOOM_FILTER_WORDS 8
+#define _Py_BLOOM_FILTER_WORDS 8
-typedef struct _bloom_filter {
- uint32_t bits[BLOOM_FILTER_WORDS];
+typedef struct {
+ uint32_t bits[_Py_BLOOM_FILTER_WORDS];
} _PyBloomFilter;
typedef struct {
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
} _PyVMData;
-#define UOP_FORMAT_TARGET 0
-#define UOP_FORMAT_EXIT 1
-#define UOP_FORMAT_JUMP 2
-#define UOP_FORMAT_UNUSED 3
-
/* Depending on the format,
* the 32 bits between the oparg and operand are:
* UOP_FORMAT_TARGET:
uint64_t operand; // A cache entry
} _PyUOpInstruction;
-static inline uint32_t uop_get_target(const _PyUOpInstruction *inst)
-{
- assert(inst->format == UOP_FORMAT_TARGET);
- return inst->target;
-}
-
-static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst)
-{
- assert(inst->format == UOP_FORMAT_EXIT);
- return inst->exit_index;
-}
-
-static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst)
-{
- assert(inst->format == UOP_FORMAT_JUMP);
- return inst->jump_target;
-}
-
-static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
-{
- assert(inst->format != UOP_FORMAT_TARGET);
- return inst->error_target;
-}
-
-typedef struct _exit_data {
+typedef struct {
uint32_t target;
_Py_BackoffCounter temperature;
const struct _PyExecutorObject *executor;
typedef struct _PyOptimizerObject _PyOptimizerObject;
/* Should return > 0 if a new executor is created. O if no executor is produced and < 0 if an error occurred. */
-typedef int (*optimize_func)(
+typedef int (*_Py_optimize_func)(
_PyOptimizerObject* self, struct _PyInterpreterFrame *frame,
_Py_CODEUNIT *instr, _PyExecutorObject **exec_ptr,
int curr_stackentries);
struct _PyOptimizerObject {
PyObject_HEAD
- optimize_func optimize;
+ _Py_optimize_func optimize;
/* Data needed by the optimizer goes here, but is opaque to the VM */
};
PyObject *const_val; // Owned reference (!)
};
+#define UOP_FORMAT_TARGET 0
+#define UOP_FORMAT_EXIT 1
+#define UOP_FORMAT_JUMP 2
+#define UOP_FORMAT_UNUSED 3
+
+static inline uint32_t uop_get_target(const _PyUOpInstruction *inst)
+{
+ assert(inst->format == UOP_FORMAT_TARGET);
+ return inst->target;
+}
+
+static inline uint16_t uop_get_exit_index(const _PyUOpInstruction *inst)
+{
+ assert(inst->format == UOP_FORMAT_EXIT);
+ return inst->exit_index;
+}
+
+static inline uint16_t uop_get_jump_target(const _PyUOpInstruction *inst)
+{
+ assert(inst->format == UOP_FORMAT_JUMP);
+ return inst->jump_target;
+}
+
+static inline uint16_t uop_get_error_target(const _PyUOpInstruction *inst)
+{
+ assert(inst->format != UOP_FORMAT_TARGET);
+ return inst->error_target;
+}
+
// Holds locals, stack, locals, stack ... co_consts (in that order)
#define MAX_ABSTRACT_INTERP_SIZE 4096
inst->oparg = oparg;
executor->vm_data.valid = true;
executor->vm_data.linked = false;
- for (int i = 0; i < BLOOM_FILTER_WORDS; i++) {
+ for (int i = 0; i < _Py_BLOOM_FILTER_WORDS; i++) {
assert(executor->vm_data.bloom.bits[i] == 0);
}
#ifdef Py_DEBUG
void
_Py_BloomFilter_Init(_PyBloomFilter *bloom)
{
- for (int i = 0; i < BLOOM_FILTER_WORDS; i++) {
+ for (int i = 0; i < _Py_BLOOM_FILTER_WORDS; i++) {
bloom->bits[i] = 0;
}
}
static bool
bloom_filter_may_contain(_PyBloomFilter *bloom, _PyBloomFilter *hashes)
{
- for (int i = 0; i < BLOOM_FILTER_WORDS; i++) {
+ for (int i = 0; i < _Py_BLOOM_FILTER_WORDS; i++) {
if ((bloom->bits[i] & hashes->bits[i]) != hashes->bits[i]) {
return false;
}
_Py_ExecutorInit(_PyExecutorObject *executor, const _PyBloomFilter *dependency_set)
{
executor->vm_data.valid = true;
- for (int i = 0; i < BLOOM_FILTER_WORDS; i++) {
+ for (int i = 0; i < _Py_BLOOM_FILTER_WORDS; i++) {
executor->vm_data.bloom.bits[i] = dependency_set->bits[i];
}
link_executor(executor);