-
Notifications
You must be signed in to change notification settings - Fork 547
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
Rust 1.74 #16416
base: dw/use-latest-master-proof-systems
Are you sure you want to change the base?
Rust 1.74 #16416
Changes from 25 commits
4385e33
e27eb17
ce13ec2
f671fae
60353ad
75b29dc
e8014cc
dfdb0f8
a1441a6
fb7ac1e
6b98a9d
5e3c507
02bcee2
b1f0a26
8255311
3593766
fe13da1
5c838a5
1b76fed
e696ce8
26a78dc
becb09c
c1c89df
2cc26fa
2ec9256
1b667e5
d0b632d
a4a992f
308fa27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
[build] | ||
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"] | ||
|
||
[source.crates-io] | ||
replace-with = "vendored-sources" | ||
|
||
[source.vendored-sources] | ||
directory = "kimchi-stubs-vendors" | ||
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
macro_rules! impl_caml_pointer { | ||
($name: ident => $typ: ty) => { | ||
#[derive(std::fmt::Debug, Clone, ::ocaml_gen::CustomType)] | ||
pub struct $name(pub ::std::rc::Rc<$typ>); | ||
pub struct $name(pub ::std::rc::Rc<std::cell::UnsafeCell<$typ>>); | ||
|
||
impl $name { | ||
extern "C" fn caml_pointer_finalize(v: ocaml::Raw) { | ||
|
@@ -12,8 +12,8 @@ macro_rules! impl_caml_pointer { | |
} | ||
|
||
extern "C" fn caml_pointer_compare(_: ocaml::Raw, _: ocaml::Raw) -> i32 { | ||
// Always return equal. We can use this for sanity checks, and anything else using this | ||
// would be broken anyway. | ||
// Always return equal. We can use this for sanity checks, and | ||
// anything else using this would be broken anyway. | ||
0 | ||
} | ||
} | ||
|
@@ -32,15 +32,17 @@ macro_rules! impl_caml_pointer { | |
|
||
impl $name { | ||
pub fn create(x: $typ) -> $name { | ||
$name(::std::rc::Rc::new(x)) | ||
$name(::std::rc::Rc::new(std::cell::UnsafeCell::new(x))) | ||
} | ||
} | ||
|
||
impl ::std::ops::Deref for $name { | ||
type Target = $typ; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&*self.0 | ||
unsafe { | ||
martyall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&*self.0.get() | ||
} | ||
} | ||
} | ||
|
||
|
@@ -49,14 +51,15 @@ macro_rules! impl_caml_pointer { | |
unsafe { | ||
// Wholely unsafe, Batman! | ||
// We would use [`get_mut_unchecked`] here, but it is nightly-only. | ||
// Instead, we get coerce our constant pointer to a mutable pointer, in the knowledge | ||
// that | ||
// * all of our mutations called from OCaml are blocking, so we won't have multiple | ||
// live mutable references live simultaneously, and | ||
// * the underlying pointer is in the correct state to be mutable, since we can call | ||
// [`get_mut_unchecked`] in nightly, or can call [`get_mut`] and unwrap if this is | ||
// Instead, we use UnsafeCell in the knowledge that | ||
// * all of our mutations called from OCaml are blocking, so | ||
// we won't have multiple live mutable references | ||
// simultaneously, and | ||
// * the underlying pointer is in the correct state to be | ||
// mutable, since we can call [`get_mut_unchecked`] in | ||
// nightly, or can call [`get_mut`] and unwrap if this is | ||
// the only live reference. | ||
&mut *(((&*self.0) as *const Self::Target) as *mut Self::Target) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
&mut *self.0.get() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: implementation of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This makes me think someone was trying to get around using |
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note as it is important for the Caml binding: UnsafeCell is implemented as:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we're adding a new indirection? We might lose some performances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nightly tests were passing with this change, does this mean that that the ocaml bindings lib was able to resolve this on its own or is it just coincidence because maybe the runtime rep is the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intuition is that this
UnsafeCell
should be optimized away. We can discuss