Skip to content

Commit

Permalink
Conditional branches in orange, fix the custom error
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney committed Aug 3, 2021
1 parent 99994a3 commit a0c1c90
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Optimization flags that were applied to a function during compilation are available in JitInfo.optimizations
* All optimizations are now runtime flags instead of compile-time features.
* Unboxing PGC errors will raise pyjion.PyjionUnboxingError (ValueError) instead of ValueError
* Instruction graphs will show conditional branches (in orange)

## 1.0.0 (rc1)

Expand Down
2 changes: 1 addition & 1 deletion Tests/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main(int argc, char* const argv[]) {
g_pyjionSettings.debug = true;
g_pyjionSettings.tracing = true;
g_pyjionSettings.codeObjectSizeLimit = 1000000;
setOptimizationLevel(1);
setOptimizationLevel(0);
int result = Catch::Session().run(argc, argv);

Py_Finalize();
Expand Down
5 changes: 4 additions & 1 deletion src/pyjion/instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,15 @@ PyObject* InstructionGraph::makeGraph(const char* name) {
PyUnicode_AppendAndDel(&g,PyUnicode_FromFormat("\tOP%u -> OP%u [label=\"Jump\" color=yellow];\n", node.second.index, node.second.index + node.second.oparg));
break;
case JUMP_ABSOLUTE:
PyUnicode_AppendAndDel(&g,PyUnicode_FromFormat("\tOP%u -> OP%u [label=\"Jump\" color=yellow];\n", node.second.index, node.second.oparg));
break;
case JUMP_IF_FALSE_OR_POP:
case JUMP_IF_TRUE_OR_POP:
case JUMP_IF_NOT_EXC_MATCH:
case POP_JUMP_IF_TRUE:
case POP_JUMP_IF_FALSE:
PyUnicode_AppendAndDel(&g,PyUnicode_FromFormat("\tOP%u -> OP%u [label=\"Jump\" color=yellow];\n", node.second.index, node.second.oparg));
PyUnicode_AppendAndDel(&g,PyUnicode_FromFormat("\tOP%u -> OP%u [label=\"Jump (conditional)\" color=orange];\n", node.second.index, node.second.index + 2));
PyUnicode_AppendAndDel(&g,PyUnicode_FromFormat("\tOP%u -> OP%u [label=\"Jump (conditional)\" color=orange];\n", node.second.index, node.second.oparg));
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/pyjion/intrins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2794,6 +2794,7 @@ long long PyJit_LongAsLongLong(PyObject* vv){
}

void PyJit_PgcGuardException(PyObject* obj, const char* expected) {
assert(PyjionUnboxingError != nullptr);
PyErr_Format(PyjionUnboxingError,
"Pyjion PGC expected %s, but %s is a %s.",
expected,
Expand Down
2 changes: 1 addition & 1 deletion src/pyjion/pyjit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ static struct PyModuleDef pyjionmodule = {
or -1 if the module keeps state in global variables. */
PyjionMethods
};

PyObject* PyjionUnboxingError;
PyMODINIT_FUNC PyInit__pyjion(void)
{
// Install our frame evaluation function
Expand Down
2 changes: 1 addition & 1 deletion src/pyjion/pyjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class PyjionJittedCode {
};

void setOptimizationLevel(unsigned short level);
static PyObject* PyjionUnboxingError;
extern PyObject* PyjionUnboxingError;
#ifdef WINDOWS
HMODULE GetClrJit();
#endif
Expand Down

0 comments on commit a0c1c90

Please sign in to comment.