flat assembler
Message board for the users of flat assembler.

Index > Windows > Register preservation in threads

Author
Thread Post new topic Reply to topic
r22



Joined: 27 Dec 2004
Posts: 805
r22
I have a heavily optimized worker thread for a Win64 program and while preserving the registers is not much overhead at all I was wondering if it is really necessary.

You preserve registers inside of calls that your program makes or inside of procedures of a DLL but do you need to inside of a thread procedure.

The thread has it's own context so destroying every register (r0-r15 and xmm0-xmm15) shouldn't affect anything else ... am I right in assuming this?
Post 03 Nov 2006, 02:30
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
Goplat
Thread procedures don't need to save the registers, but if you're worried about that overhead you might want to consider the time it takes to create and destroy a thread, which is likely far more.
Post 03 Nov 2006, 03:10
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
Thanks thats what I figured.

This was more of a programming standard and convention question than an optimization question.
Quote:

while preserving the registers is not much overhead at all I was wondering if it is really necessary.


Although avoiding
Code:
push rbp rbx rsi rdi r12 r13 r14 r15
movdqa [rsp+??],xmm6 - xmm15
...
movdqa xmm6 - xmm15, [rsp+??]
pop r15 r14 r13 r12 rdi rsi rbx rbp
    

Could be considered a significant 'size' optimization.
Post 03 Nov 2006, 04:01
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Maverick



Joined: 07 Aug 2006
Posts: 251
Location: Citizen of the Universe
Maverick
Looks like the 680x0, with the difference that it did it in hardware Very Happy
Post 03 Nov 2006, 07:03
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Dunno if you need register preservation in the thread. If you "ret" you might - no way to tell whether your code would break on a future service pack. If you "call ExitThread" you probably don't, but perhaps that's more overhead than preservation + ret.
Post 03 Nov 2006, 08:18
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.