Skip to content
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.

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

Add global data API, rewrite chan_from_global_ptr #3915

Closed
brson opened this issue Nov 4, 2012 · 7 comments
Closed

Add global data API, rewrite chan_from_global_ptr #3915

brson opened this issue Nov 4, 2012 · 7 comments

Comments

@brson
Copy link
Contributor

brson commented Nov 4, 2012

It would be similar to the local data API, except that values are probably RWARCs for mutable data and ARCs for immutablel data.

Then chan_from_global_ptr could be expressed in terms of the global data API, storing a pipe-based channel, which would get it away from using core::comm.

linenoise also needs a global mutex, which this would provide.

There's some question about where the constructor runs, but the API could just hand you a RWARC<Option<T>> and let you figure it out - presumably anybody using this API would encapsulate it in something else. The hard part is deciding when to do the cleanup and whether to allow destructors. The obvious thing I can think of is to have a weak task do it, and weak tasks have to know not to rely on global data during shutdown.

Like the local data API it would be unsafe until we have a good way to name the key.

Related to #553

@brson
Copy link
Contributor Author

brson commented Nov 4, 2012

getenv/setenv could also just use the RWARC's as mutexes and not create an entire task

@Blub
Copy link

Blub commented Nov 9, 2012

Would that mean all globals are *ARCs? Or would I be able to make "normal" globals, too. Because more often than not I want to avoid the overhead of an ARC.
Personally I also wouldn't mind "uninitialized" globals - there could be unsafe builtin to set a variable without caring about its previous contents. (So that you can initialize a global @ptr without it trying to deallocate the previous (invalid) data. (Or they they could live in the data section with their reference count initialized to 2 or something, but that wouldn't solve the issue for ~ptrs)

@brson
Copy link
Contributor Author

brson commented Nov 9, 2012

@Blub, this API is intended to be safe, so ARCs make the most sense to me. There is another proposal for adding unsafe globals to the language: #553.

Plain ARCs though have, in theory, no overhead to read, while RWARCs do involve locking.

Also, global @-pointers would be very unsafe.

@Blub
Copy link

Blub commented Nov 9, 2012

I don't think global @-pointers are required, but ARCs are read-only, and RWARCs add overhead, this is my main concern. I think this and #553 should go hand in hand: mut-globals which are declared as unsafe should not be RWARC-guarded. I'd really like to use mutable globals, but I would definitely not use RWARCs in my current usecases.

@brson
Copy link
Contributor Author

brson commented Jan 11, 2013

Rewriting chan_from_global_ptr also requires rewriting weaken_task since the use of the two of them together necessitates selecting on two ports, and those two ports must be the same sort of port.

brson added a commit to brson/rust that referenced this issue Jan 13, 2013
brson added a commit to brson/rust that referenced this issue Jan 18, 2013
brson added a commit to brson/rust that referenced this issue Jan 22, 2013
brson added a commit to brson/rust that referenced this issue Jan 24, 2013
@catamorphism
Copy link
Contributor

@brson Still relevant?

@brson
Copy link
Contributor Author

brson commented May 29, 2013

This is done.

@brson brson closed this as completed May 29, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 29, 2024
switch custom target JSON test to a less exotic target

We used to test an AVR target here, but while it is nice to test a 16bit target, it is also currently the case that rustc CI does not even check that libcore builds on a 16bit target -- and we don't want Miri to be in the game of maintaining that support. (See rust-lang#130818.)

So let's use a tier 2 target as the basis for testing a custom JSON target.

(FWIW, we also test wasm32-wasip2 which is tier 3, but I expect it will become tier 2 Soon-ish.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants