GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-98831: rewrite RAISE_VARARGS in the instruction definition DSL by iritkatriel · Pull Request #101306 · python/cpython

gh-98831: rewrite RAISE_VARARGS in the instruction definition DSL #101306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
iritkatriel merged 7 commits into python:main from iritkatriel:RAISE_VARARG
Jan 25, 2023

Uh oh!

There was an error while loading. Please reload this page.

Merged

gh-98831: rewrite RAISE_VARARGS in the instruction definition DSL #101306

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
7 commits
Select commit Hold shift + click to select a range
7fe1602
gh-98831: rewrite RAISE_VARARGS in the instruction definition DSL
iritkatriel Jan 24, 2023
6d1e184
Merge branch 'main' into RAISE_VARARG
iritkatriel Jan 25, 2023
6071503
avoid emitting dead code
iritkatriel Jan 25, 2023
2daaa2e
apply Guido's suggestion
iritkatriel Jan 25, 2023
d87d9af
Merge remote-tracking branch 'upstream/main' into RAISE_VARARG
iritkatriel Jan 25, 2023
4df3e6b
regen
iritkatriel Jan 25, 2023
06ac7dd
avoid 'unused function' warnings
iritkatriel Jan 25, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

13 changes: 5 additions & 8 deletions 13 Python/bytecodes.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -505,27 +505,24 @@ dummy_func(
ERROR_IF(res == NULL, error);
}

// This should remain a legacy instruction.
inst(RAISE_VARARGS) {
inst(RAISE_VARARGS, (args[oparg] -- )) {
PyObject *cause = NULL, *exc = NULL;
switch (oparg) {
case 2:
cause = POP(); /* cause */
cause = args[1];
/* fall through */
case 1:
exc = POP(); /* exc */
exc = args[0];
/* fall through */
case 0:
if (do_raise(tstate, exc, cause)) {
goto exception_unwind;
}
ERROR_IF(do_raise(tstate, exc, cause), exception_unwind);
break;
default:
_PyErr_SetString(tstate, PyExc_SystemError,
"bad RAISE_VARARGS oparg");
break;
}
goto error;
ERROR_IF(true, error);
}

inst(INTERPRETER_EXIT, (retval --)) {
Expand Down
11 changes: 5 additions & 6 deletions 11 Python/generated_cases.c.h
Show comments
View file
Open in desktop

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

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

8 changes: 6 additions & 2 deletions 8 Python/opcode_metadata.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// from Python/bytecodes.c
// Do not edit!

#ifndef NDEBUG
static int
_PyOpcode_num_popped(int opcode, int oparg) {
switch(opcode) {
Expand Down Expand Up @@ -86,7 +87,7 @@ _PyOpcode_num_popped(int opcode, int oparg) {
case CALL_INTRINSIC_1:
return 1;
case RAISE_VARARGS:
return -1;
return oparg;
case INTERPRETER_EXIT:
return 1;
case RETURN_VALUE:
Expand Down Expand Up @@ -345,7 +346,9 @@ _PyOpcode_num_popped(int opcode, int oparg) {
Py_UNREACHABLE();
}
}
#endif

#ifndef NDEBUG
static int
_PyOpcode_num_pushed(int opcode, int oparg) {
switch(opcode) {
Expand Down Expand Up @@ -430,7 +433,7 @@ _PyOpcode_num_pushed(int opcode, int oparg) {
case CALL_INTRINSIC_1:
return 1;
case RAISE_VARARGS:
return -1;
return 0;
case INTERPRETER_EXIT:
return 0;
case RETURN_VALUE:
Expand Down Expand Up @@ -689,6 +692,7 @@ _PyOpcode_num_pushed(int opcode, int oparg) {
Py_UNREACHABLE();
}
}
#endif
enum Direction { DIR_NONE, DIR_READ, DIR_WRITE };
enum InstructionFormat { INSTR_FMT_IB, INSTR_FMT_IBC, INSTR_FMT_IBC0, INSTR_FMT_IBC000, INSTR_FMT_IBIB, INSTR_FMT_IX, INSTR_FMT_IXC, INSTR_FMT_IXC000 };
struct opcode_metadata {
Expand Down
6 changes: 4 additions & 2 deletions 6 Tools/cases_generator/generate_cases.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,8 @@ def write_stack_effect_functions(self) -> None:
pushed_data.append( (instr, pushed) )

def write_function(direction: str, data: list[tuple[Instruction, str]]) -> None:
self.out.emit("\nstatic int");
self.out.emit("\n#ifndef NDEBUG");
self.out.emit("static int");
self.out.emit(f"_PyOpcode_num_{direction}(int opcode, int oparg) {{")
self.out.emit(" switch(opcode) {");
for instr, effect in data:
Expand All @@ -784,6 +785,7 @@ def write_function(direction: str, data: list[tuple[Instruction, str]]) -> None:
self.out.emit(" Py_UNREACHABLE();")
self.out.emit(" }")
self.out.emit("}")
self.out.emit("#endif");

write_function('popped', popped_data)
write_function('pushed', pushed_data)
Expand Down Expand Up @@ -1023,7 +1025,7 @@ def always_exits(lines: list[str]) -> bool:
return False
line = line[12:]
return line.startswith(
("goto ", "return ", "DISPATCH", "GO_TO_", "Py_UNREACHABLE()")
("goto ", "return ", "DISPATCH", "GO_TO_", "Py_UNREACHABLE()", "ERROR_IF(true, ")
)


Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.