mozilla/rust — Issue #1508: Allow C code to call into Rust code
Author: brson
Created: 2012-01-13 20:57:30+00:00
State: open
Labels: design, feature, rt, trans, unassigned

There are probably a number of things needed to make this happen:

Scheduler:

* Instead of reusing the scheduler's stack to call C code, we'll want each scheduler thread to hold a cache of big stacks, give each task a pointer to a C stack, a stack of C contexts and a stack of Rust contexts.
* When calling into C code, if the task already has a C stack it reuses it, if not it checks whether the scheduler has any C stacks and pops one, or it allocates a new one, and pushes the Rust context onto the Rust context stack.
* &c.
* When it pops the last Rust context it returns the C stack to the scheduler's pool.

Language:

* Would be really nice to be able to create functions with appropriate native signatures such that they could be called directly

Extensions:

* Any glue that might be needed could be generated via a syntax extension.