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 — bpo-45256: Remove the usage of the C stack in Python to Python calls by pablogsal · Pull Request #28488 · python/cpython

bpo-45256: Remove the usage of the C stack in Python to Python calls #28488

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
pablogsal merged 17 commits into python:main from pablogsal:simple_cframe
Oct 9, 2021

Uh oh!

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

Merged

bpo-45256: Remove the usage of the C stack in Python to Python calls #28488

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8a88fd3
Remove the usage of the cstack in Python to Python calls
pablogsal Sep 17, 2021
799e366
Fix gdb
pablogsal Sep 17, 2021
306e29f
Move depth to frame structure for easier retrieval in debugging tools
pablogsal Sep 17, 2021
fc36be1
Refactor and simplifications
pablogsal Sep 17, 2021
e1091e0
Fix existing bug in the PREDICT() macro for the codepath without comp…
pablogsal Sep 21, 2021
d7a99c1
Apply suggestions from code review
pablogsal Sep 21, 2021
0721cea
Tracing of Python functions is handled at entry not call.
markshannon Sep 23, 2021
a2c0994
Inline creation of coroutines.
markshannon Sep 23, 2021
832bccf
Merge remote-tracking branch 'upstream/main' into simple_cframe
pablogsal Sep 23, 2021
9a63ee1
Reorder flow in CALL_FUNCTION to make it a bit clearer.
markshannon Sep 23, 2021
919b741
Merge pull request #16 from markshannon/simple_cframe
pablogsal Sep 23, 2021
9210541
Update Python/ceval.c
pablogsal Sep 23, 2021
9ce9e63
Fix reference counting when creating a new interpreter frame fails.
markshannon Sep 24, 2021
9a0ceab
Remove _PyEval_FrameFromPyFunctionAndArgs forwarding function.
markshannon Sep 24, 2021
65219b2
Merge pull request #17 from markshannon/simple_cframe
pablogsal Sep 24, 2021
1de88f6
Fix reference leaks (needs cleanup)
pablogsal Sep 29, 2021
f313e8c
Merge branch 'main' into simple_cframe
pablogsal Oct 7, 2021
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

2 changes: 2 additions & 0 deletions 2 Include/internal/pycore_frame.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct _interpreter_frame {
int f_lasti; /* Last instruction if called */
int stacktop; /* Offset of TOS from localsplus */
PyFrameState f_state; /* What state the frame is in */
int depth; /* Depth of the frame in a ceval loop */
Comment thread
pablogsal marked this conversation as resolved.
Resolved

Uh oh!

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

Comment thread
pablogsal marked this conversation as resolved.
Resolved

Uh oh!

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

PyObject *localsplus[1];
} InterpreterFrame;

Expand Down Expand Up @@ -85,6 +86,7 @@ _PyFrame_InitializeSpecials(
frame->generator = NULL;
frame->f_lasti = -1;
frame->f_state = FRAME_CREATED;
frame->depth = 0;
}

/* Gets the pointer to the locals array
Expand Down
1 change: 1 addition & 0 deletions 1 Include/internal/pycore_tuple.h
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern "C" {
#define _PyTuple_ITEMS(op) (_PyTuple_CAST(op)->ob_item)

extern PyObject *_PyTuple_FromArray(PyObject *const *, Py_ssize_t);
extern PyObject *_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion 2 Lib/test/gdb_sample.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sample script for use by test_gdb.py

def foo(a, b, c):
bar(a, b, c)
bar(a=a, b=b, c=c)

def bar(a, b, c):
baz(a, b, c)
Expand Down
26 changes: 23 additions & 3 deletions 26 Lib/test/test_gdb.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,14 @@ def test_pyup_command(self):
cmds_after_breakpoint=['py-up', 'py-up'])
self.assertMultilineMatches(bt,
r'''^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
id\(42\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
bar\(a=a, b=b, c=c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
foo\(1, 2, 3\)
$''')

@unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
Expand Down Expand Up @@ -763,10 +769,18 @@ def test_up_then_down(self):
cmds_after_breakpoint=['py-up', 'py-up', 'py-down'])
self.assertMultilineMatches(bt,
r'''^.*
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
id\(42\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
bar\(a=a, b=b, c=c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
foo\(1, 2, 3\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
id\(42\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
$''')

class PyBtTests(DebuggerTests):
Expand All @@ -785,7 +799,7 @@ def test_bt(self):
File ".*gdb_sample.py", line 7, in bar
baz\(a, b, c\)
File ".*gdb_sample.py", line 4, in foo
bar\(a, b, c\)
bar\(a=a, b=b, c=c\)
File ".*gdb_sample.py", line 12, in <module>
foo\(1, 2, 3\)
''')
Expand All @@ -801,7 +815,7 @@ def test_bt_full(self):
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
bar\(a, b, c\)
bar\(a=a, b=b, c=c\)
#[0-9]+ Frame 0x-?[0-9a-f]+, for file .*gdb_sample.py, line 12, in <module> \(\)
foo\(1, 2, 3\)
''')
Expand Down Expand Up @@ -1008,7 +1022,13 @@ def test_locals_after_up(self):
bt = self.get_stack_trace(script=self.get_sample_script(),
cmds_after_breakpoint=['py-up', 'py-up', 'py-locals'])
self.assertMultilineMatches(bt,
r".*\na = 1\nb = 2\nc = 3\n.*")
r'''^.*
Locals for foo
a = 1
b = 2
c = 3
Locals for <module>
.*$''')


def setUpModule():
Expand Down
20 changes: 20 additions & 0 deletions 20 Objects/tupleobject.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,26 @@ _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
return (PyObject *)tuple;
}

PyObject *
_PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n)
{
if (n == 0) {
return tuple_get_empty();
}

PyTupleObject *tuple = tuple_alloc(n);
if (tuple == NULL) {
return NULL;
}
PyObject **dst = tuple->ob_item;
for (Py_ssize_t i = 0; i < n; i++) {
PyObject *item = src[i];
dst[i] = item;
}
_PyObject_GC_TRACK(tuple);
return (PyObject *)tuple;
}

static PyObject *
tupleslice(PyTupleObject *a, Py_ssize_t ilow,
Py_ssize_t ihigh)
Expand Down
Loading
Oops, something went wrong.

Uh oh!

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

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 01402520 — 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.