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

Adopt C#/Rust-style unsafe contexts #44

Open
2 tasks
densh opened this issue May 10, 2016 · 5 comments
Open
2 tasks

Adopt C#/Rust-style unsafe contexts #44

densh opened this issue May 10, 2016 · 5 comments

Comments

@densh
Copy link
Member

densh commented May 10, 2016

Unsafe (pointers, stack allocation, extern calls and friends) features can only be used in unsafe context:

  • @unsafe methods
  • unsafe { ... } blocks

This clearly demarcates usage of unsafe features, making it impossible to use them by accident.

@densh densh added this to the M3 milestone May 10, 2016
@rightfold
Copy link

Do calls to @unsafe methods count as unsafe, like in Rust (and unlike in C#, where unsafe is always lexical)?

@densh densh changed the title Adopt C#-style unsafe contexts Adopt C#/Rust-style unsafe contexts May 13, 2016
@densh
Copy link
Member Author

densh commented May 13, 2016

Yes, they do count as unsafe.

@rightfold
Copy link

Yay!

@densh densh modified the milestones: Backlog, M3 May 21, 2016
@densh densh modified the milestones: M4, Backlog Jun 6, 2016
@densh densh modified the milestones: Backlog, M4 Jul 15, 2016
@densh densh added the feature label Jan 3, 2017
@gurinderu
Copy link
Contributor

@densh Could you add an ability to use IR code in this task or maybe in separate?

For example

def start: Unit ={
 ir{
  %src.2 = alloca %"scala.scalanative.runtime.OmrThread"
  %src.3 = bitcast %"scala.scalanative.runtime.OmrThread"* %src.2 to i8*
  %src.4 = alloca void(...)*, align 8
  store void (...)* bitcast (void (i8*)* @"java.lang.Thread::run_unit" to void (...)*), void (...)** %src.4, align 8
  %src.5 = load void (...)*, void (...)** %src.4, align 8
  %src.6 = bitcast void (...)* %src.5 to i8*
  call void (i8*, i8*, i32, i8*, i8*) @"omrthread_create_ex"(i8* %src.3, i8* zeroinitializer, i32 0, i8* %src.6, i8* zeroinitializer)
 }
}

Also, it would be perfect to add annotation which marks method us usable in IR and does not remove them in dead code elimination phase

@densh
Copy link
Member Author

densh commented Jan 7, 2017

@gurinderu Including inline IR in the code is not something that we are going to support. IR is subject to change without further notice, it's not meant to be stable. We want to have freedom to innovate in this area without breaking end-users code.

Regarding the second feature suggestion, I do not quite get exactly what you mean. Lets discuss on gitter. Also please try to refrain from suggesting new features in issues which are not strictly related to your suggestion (like this one.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants