Hi everyone,

I noticed some unfortunate disassembly recently and am curious about 
whether y'all are aware of this problem or have any ideas about how to fix 
it.

Problem description:

The Clang preserve_most attribute defines a new calling convention where 
all floating-point registers are caller-saved. This is a mismatch with the 
normal Windows calling convention, and causes any caller of a 
V8_PRESERVE_MOST function to save and restore xmm6 through xmm15, at a cost 
of 126 bytes of extra instructions per calling function. When there are 
many callers to a V8_PRESERVE_MOST function, this size cost adds up: for 
example, there are many hundreds of instantiations of the template 
AllocationDispatcher::Invoke in Chromium, and each one calls a 
V8_PRESERVE_MOST function. I tried disabling V8_PRESERVE_MOST and found 
that it reduced the size of a release build of chrome.dll by a whopping 2 
MB.

The preserve_most calling convention is working correctly, as defined at 
https://clang.llvm.org/docs/AttributeReference.html#preserve-most . 
However, it's a bad fit for Windows. This problem has been raised in the 
LLVM discussion forum: 
https://discourse.llvm.org/t/conv-c-and-conv-preservemost-mix-badly-on-windows-x64/73054
 
.

The discussion question: what should we do about this? I could imagine a 
few answers:

1. Do nothing; it's working fine and we're okay with the code-size cost
2. Disable preserve_most for Windows builds, since the cost of saving and 
restoring all of those floating-point registers outweighs the benefit of 
avoiding similar stack access for general-purpose registers
3. Redefine preserve_most in a platform-specific way so it treats xmm6 
through xmm15 as callee-save on Windows
4. Define a new Clang attribute preserve_most_win which is like 
preserve_most but with Windows semantics for floating-point registers
5. Use preserve_all instead on Windows, to declare that all floating-point 
registers are callee-save. This is appealing because it pushes the cost of 
saving and restoring into the cold function, but when I tried it, I got a 
bunch of internal compiler errors.

Best,
Seth

-- 
-- 
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/3e5b967d-553e-40dd-ad7b-4a606d750f85n%40googlegroups.com.

Reply via email to