Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove docs for super-instructions
Also tweak the text some more.
  • Loading branch information
gvanrossum committed Jun 13, 2023
commit 7f0b62332a189221fde00c53f10c724e3c33ccd5
34 changes: 6 additions & 28 deletions Tools/cases_generator/interpreter_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ and a piece of C code describing its semantics::
"op" "(" NAME "," stack_effect ")" "{" C-code "}"
|
"macro" "(" NAME ")" "=" uop ("+" uop)* ";"
|
"super" "(" NAME ")" "=" NAME ("+" NAME)* ";"

stack_effect:
"(" [inputs] "--" [outputs] ")"
Expand Down Expand Up @@ -130,8 +128,6 @@ The following definitions may occur:
* `inst`: A normal instruction, as previously defined by `TARGET(NAME)` in `ceval.c`.
* `op`: A part instruction from which macros can be constructed.
* `macro`: A bytecode instruction constructed from ops and cache effects.
* `super`: A super-instruction, such as `LOAD_FAST__LOAD_FAST`, constructed from
normal or macro instructions.

`NAME` can be any ASCII identifier that is a C identifier and not a C or Python keyword.
`foo_1` is legal. `$` is not legal, nor is `struct` or `class`.
Expand Down Expand Up @@ -167,7 +163,7 @@ part of the DSL.
Those functions include:

* `DEOPT_IF(cond, instruction)`. Deoptimize if `cond` is met.
* `ERROR_IF(cond, label)`. Jump to error handler if `cond` is true.
* `ERROR_IF(cond, label)`. Jump to error handler at `label` if `cond` is true.
* `DECREF_INPUTS()`. Generate `Py_DECREF()` calls for the input stack effects.

Note that the use of `DECREF_INPUTS()` is optional -- manual calls
Expand All @@ -193,10 +189,13 @@ These requirements result in the following constraints on the use of
intermediate results.)
3. No `DEOPT_IF` may follow an `ERROR_IF` in the same block.

If an error condition is detected before the first `DECREF` of an input,
(There is some wiggle room: these rules apply to dynamic code paths,
not to static occurrences in the source code.)

If code detects an error condition before the first `DECREF` of an input,
two idioms are valid:

- Just use `goto error`.
- Use `goto error`.
- Use a block containing the appropriate `DECREF` calls ending in
`ERROR_IF(true, error)`.

Expand Down Expand Up @@ -259,27 +258,6 @@ This would generate:
}
```

### Super-instruction definition

```C
super ( LOAD_FAST__LOAD_FAST ) = LOAD_FAST + LOAD_FAST ;
```
This might get translated into the following:
```C
TARGET(LOAD_FAST__LOAD_FAST) {
PyObject *value;
value = frame->f_localsplus[oparg];
Py_INCREF(value);
PUSH(value);
NEXTOPARG();
next_instr++;
value = frame->f_localsplus[oparg];
Py_INCREF(value);
PUSH(value);
DISPATCH();
}
```

### Input stack effect and cache effect
```C
op ( CHECK_OBJECT_TYPE, (owner, type_version/2 -- owner) ) {
Expand Down