Skip to content

Commit

Permalink
PROGRESS
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom authored and iritkatriel committed Dec 3, 2024
1 parent 69864b4 commit 8eddfea
Show file tree
Hide file tree
Showing 18 changed files with 683 additions and 370 deletions.
3 changes: 3 additions & 0 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ struct _typeobject {
/* bitset of which type-watchers care about this type */
unsigned char tp_watched;
uint16_t tp_versions_used;

/* hooks to specializers */
binaryopspecfunc tp_binary_op_specialize;
};

/* This struct is used by the specializer
Expand Down
15 changes: 15 additions & 0 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ typedef struct {

typedef struct {
_Py_BackoffCounter counter;
uint16_t external_cache[4];
} _PyBinaryOpCache;

#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache)
Expand Down Expand Up @@ -436,6 +437,12 @@ write_obj(uint16_t *p, PyObject *val)
memcpy(p, &val, sizeof(val));
}

static inline void
write_void(uint16_t *p, void *val)
{
memcpy(p, &val, sizeof(val));
}

static inline uint16_t
read_u16(uint16_t *p)
{
Expand Down Expand Up @@ -466,6 +473,14 @@ read_obj(uint16_t *p)
return val;
}

static inline void *
read_void(uint16_t *p)
{
void *val;
memcpy(&val, p, sizeof(val));
return val;
}

/* See Objects/exception_handling_notes.txt for details.
*/
static inline unsigned char *
Expand Down
8 changes: 8 additions & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,17 @@ struct _is {
/* the initial PyInterpreterState.threads.head */
_PyThreadStateImpl _initial_thread;
Py_ssize_t _interactive_src_count;

PyBinaryOpSpecializationDescr binary_op_spec[256];
};


#define BINOP_FLOAT_INT_MULTIPLY 0
#define BINOP_FLOAT_INT_SUBTRACT 1
#define BINOP_INT_FLOAT_MULTIPLY 2
#define BINOP_INT_FLOAT_SUBTRACT 3


/* other API */

extern void _PyInterpreterState_Clear(PyThreadState *tstate);
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ PC/launcher.c must also be updated.
*/

#define PYC_MAGIC_NUMBER 3607
#define PYC_MAGIC_NUMBER 3609
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
41 changes: 25 additions & 16 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8eddfea

Please sign in to comment.