Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

jpf91
Copy link
Contributor

@jpf91 jpf91 commented Jan 14, 2014

Systems which do use the C backend but the C library returns ENOSYS at runtime. (This happens on ARM with glibc < 2.17 for example).

We do not want to abort all testing in this case. We also don't want the static ctor to assert in this case whenever someone wants to use core.thread.

Note: This is part of a set of changes which are required to get test suite & unit tests passing on ARM GDC. All necessary changes for GDC are here for reference:
https://github.com/jpf91/GDC/commits/arm-old

Once these pull requests are merged upstream I'll merge them into GDC as well.

Systems which do use the C backend but the C library returns ENOSYS
at runtime. (This happens on ARM with glibc < 2.17 for example).

We do not want to abort all testing in this case.
We also don't want the static ctor to assert in this
case whenever someone wants to use core.thread.
@MartinNowak
Copy link
Member

Maybe we should rip out the ucontext_t fallback altogether?
Even if supported it adds a lot of unnecessary overhead to Fiber context switches and
the fiber_switchContext implementation is very similar to callWithStackShell. Both can easily be implemented in threadasm.S.

@MartinNowak
Copy link
Member

@jpf91
Copy link
Contributor Author

jpf91 commented Jan 19, 2014

OK we can remove ucontext_t if you want.
I've implemented the ASM for ARM now. It was more of an research task (ARM has many different fpu variants, do they have different registers? which registers must be saved? ...) but the actual implementation is really quite simple.

One remaining question: Would you say the floating point status register should be saved? It basically contains things like rounding mode, exception trap bits and exception 'occurred' bits:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0473c/Bcfhfbga.html

If we really want to micro-optimize fibers we probably have to enable inlining first. If the fiber_switchContext routines were implemented with extended inline ASM gdc should be able to inline those and hopefully the complete 'yield' function could be inlined.

@jpf91 jpf91 closed this Jan 19, 2014
@MartinNowak
Copy link
Member

OK we can remove ucontext_t if you want.

I think that would make sense, it's a bad default and as you said an asm implementation is quite simple.

One remaining question: Would you say the floating point status register should be saved? It basically contains things like rounding mode, exception trap bits and exception 'occurred' bits:

We currently don't save/restore this. I tend to think of fiber context switching as a subroutine call.

If we really want to micro-optimize fibers we probably have to enable inlining first.

Could be useful, but I wouldn't expect much gain, because the function call overhead is minimal. Also having the asm code in an extra .S file allows us to share it among all compilers.

@MartinNowak
Copy link
Member

Where is the ARM asm code btw?

@ibuclaw
Copy link
Member

ibuclaw commented Jan 20, 2014

Does __builtin_unwind_init() not do the job?

I guess we can remove that version(GNU) code and put in x86 and x86_64 code paths into threadasm.S

@MartinNowak
Copy link
Member

You'd still need code to switch the stack pointer.

@jpf91
Copy link
Contributor Author

jpf91 commented Jan 21, 2014

@MartinNowak it's not published yet. I want to test it on a system without FPU first.

@ibuclaw __builtin_unwind_init is fine for callWithStackShell but for Fibers the stack pointer must be switched and the registers have to be restored as well. AFAICS there's no builtin for that?

@ibuclaw
Copy link
Member

ibuclaw commented Jan 22, 2014

@jpf91 oh right, I see it.

@MartinNowak would it be OK to copy D IASM code in fiber_switchContext to threadasm.S? That way I could add version (GNU) version = AsmExternal locally I guess...

@ibuclaw
Copy link
Member

ibuclaw commented Jan 22, 2014

(And be one step ahead of removing ucontext_t)

@MartinNowak
Copy link
Member

@MartinNowak would it be OK to copy D IASM code in fiber_switchContext to threadasm.S? That way I could add version (GNU) version = AsmExternal locally I guess...

Sure, I wouldn't even mind to switch from D IASM to external .S file altogether.
Maybe the IASM version is required for Windows though, because we don't have an assembler? Or do we have masm...?

@jpf91
Copy link
Contributor Author

jpf91 commented Jan 25, 2014

@MartinNowak the pull request for the ARM code is here #713

@jpf91 jpf91 deleted the arm-2 branch January 25, 2014 15:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants