@@ -6,7 +6,7 @@ The CPython interpreter is defined in C, meaning that the semantics of the
6
6
bytecode instructions, the dispatching mechanism, error handling, and
7
7
tracing and instrumentation are all intermixed.
8
8
9
- This document proposes defining a custom C-like DSL for defining the
9
+ This document proposes defining a custom C-like DSL for defining the
10
10
instruction semantics and tools for generating the code deriving from
11
11
the instruction definitions.
12
12
@@ -46,7 +46,7 @@ passes from the semantic definition, reducing errors.
46
46
47
47
As we improve the performance of CPython, we need to optimize larger regions
48
48
of code, use more complex optimizations and, ultimately, translate to machine
49
- code.
49
+ code.
50
50
51
51
All of these steps introduce the possibility of more bugs, and require more code
52
52
to be written. One way to mitigate this is through the use of code generators.
@@ -62,7 +62,7 @@ blocks as the instructions for the tier 1 (PEP 659) interpreter.
62
62
Rewriting all the instructions is tedious and error-prone, and changing the
63
63
instructions is a maintenance headache as both versions need to be kept in sync.
64
64
65
- By using a code generator and using a common source for the instructions, or
65
+ By using a code generator and using a common source for the instructions, or
66
66
parts of instructions, we can reduce the potential for errors considerably.
67
67
68
68
@@ -75,7 +75,7 @@ We update it as the need arises.
75
75
76
76
Each op definition has a kind, a name, a stack and instruction stream effect,
77
77
and a piece of C code describing its semantics::
78
-
78
+
79
79
```
80
80
file:
81
81
(definition | family | pseudo)+
@@ -86,7 +86,7 @@ and a piece of C code describing its semantics::
86
86
"op" "(" NAME "," stack_effect ")" "{" C-code "}"
87
87
|
88
88
"macro" "(" NAME ")" "=" uop ("+" uop)* ";"
89
-
89
+
90
90
stack_effect:
91
91
"(" [inputs] "--" [outputs] ")"
92
92
@@ -201,6 +201,7 @@ Those functions include:
201
201
* ` DEOPT_IF(cond, instruction) ` . Deoptimize if ` cond ` is met.
202
202
* ` ERROR_IF(cond, label) ` . Jump to error handler at ` label ` if ` cond ` is true.
203
203
* ` DECREF_INPUTS() ` . Generate ` Py_DECREF() ` calls for the input stack effects.
204
+ * ` SYNC_SP() ` . Synchronizes the physical stack pointer with the stack effects.
204
205
205
206
Note that the use of ` DECREF_INPUTS() ` is optional -- manual calls
206
207
to ` Py_DECREF() ` or other approaches are also acceptable
@@ -445,7 +446,7 @@ rather than popping and pushing, such that `LOAD_ATTR_SLOT` would look something
445
446
stack_pointer += 1;
446
447
}
447
448
s1 = res;
448
- }
449
+ }
449
450
next_instr += (1 + 1 + 2 + 1 + 4);
450
451
stack_pointer[-1] = s1;
451
452
DISPATCH();
0 commit comments