Skip to content

Commit 365082f

Browse files
Address review
1 parent 1fb6792 commit 365082f

14 files changed

+1716
-207
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 11 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ typedef struct {
4848
* uint16_t error_target;
4949
*/
5050
typedef struct {
51-
uint16_t opcode:15;
51+
uint16_t opcode:14;
5252
uint16_t format:1;
53+
uint16_t is_virtual:1; // Used for tier2 optimization.
5354
uint16_t oparg;
5455
union {
5556
uint32_t target;
@@ -59,7 +60,6 @@ typedef struct {
5960
};
6061
};
6162
uint64_t operand; // A cache entry
62-
char is_virtual; // Used for tier2 optimization.
6363
} _PyUOpInstruction;
6464

6565
typedef struct {

Include/internal/pycore_stackref.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ PyStackRef_FromPyObjectImmortal(PyObject *obj)
193193
# define PyStackRef_CLOSE(REF) \
194194
do { \
195195
_PyStackRef _close_tmp = (REF); \
196-
if (!PyStackRef_IsDeferred(_close_tmp)) { \
196+
if (!i(_close_tmp)) { \
197197
Py_DECREF(PyStackRef_AsPyObjectBorrow(_close_tmp)); \
198198
} \
199199
} while (0)

Include/internal/pycore_uop_metadata.h

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ dummy_func(
140140
switch (opcode) {
141141

142142
// BEGIN BYTECODES //
143-
_static inst(NOP, (--)) {
143+
pure inst(NOP, (--)) {
144144
}
145145

146146
family(RESUME, 0) = {
@@ -239,7 +239,7 @@ dummy_func(
239239
value = PyStackRef_DUP(value_s);
240240
}
241241

242-
replicate(8) _static inst(LOAD_FAST, (-- value)) {
242+
replicate(8) pure inst(LOAD_FAST, (-- value)) {
243243
assert(!PyStackRef_IsNull(GETLOCAL(oparg)));
244244
value = PyStackRef_DUP(GETLOCAL(oparg));
245245
}
@@ -261,7 +261,7 @@ dummy_func(
261261
value = PyStackRef_FromPyObjectNew(GETITEM(FRAME_CO_CONSTS, oparg));
262262
}
263263

264-
replicate(8) _static inst(STORE_FAST, (value --)) {
264+
replicate(8) pure inst(STORE_FAST, (value --)) {
265265
SETLOCAL(oparg, value);
266266
}
267267

@@ -283,7 +283,7 @@ dummy_func(
283283
SETLOCAL(oparg2, value2);
284284
}
285285

286-
_static inst(POP_TOP, (value --)) {
286+
pure inst(POP_TOP, (value --)) {
287287
DECREF_INPUTS();
288288
}
289289

@@ -4749,11 +4749,11 @@ dummy_func(
47494749
DEOPT_IF(!current_executor->vm_data.valid);
47504750
}
47514751

4752-
tier2 _static op(_LOAD_CONST_INLINE, (ptr/4 -- value)) {
4752+
tier2 pure op(_LOAD_CONST_INLINE, (ptr/4 -- value)) {
47534753
value = PyStackRef_FromPyObjectNew(ptr);
47544754
}
47554755

4756-
tier2 _static op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {
4756+
tier2 pure op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {
47574757
value = PyStackRef_FromPyObjectImmortal(ptr);
47584758
}
47594759

Python/partial_evaluator.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,24 +216,6 @@ partial_evaluate_uops(
216216
}
217217
#endif
218218

219-
int is_static = (_PyUop_Flags[opcode] & HAS_STATIC_FLAG);
220-
if (!is_static) {
221-
MATERIALIZE_INST();
222-
}
223-
if (!is_static &&
224-
// During these two opcodes, there's an abstract frame on the stack.
225-
// Which is not a valid symbol.
226-
(opcode != _PUSH_FRAME && opcode != _SAVE_RETURN_OFFSET)) {
227-
// An escaping opcode means we need to materialize _everything_.
228-
if (_PyUop_Flags[opcode] & HAS_ESCAPES_FLAG) {
229-
materialize_ctx(ctx);
230-
}
231-
else {
232-
233-
materialize_frame(ctx->frame);
234-
}
235-
}
236-
237219
switch (opcode) {
238220

239221
#include "partial_evaluator_cases.c.h"

0 commit comments

Comments
 (0)