Use objc_msgSend_fpret for backingStoreFactor. - #74
Conversation
This mistake led to a bizarre chain reaction in Servo that ultimately led to a hang only when optimization was enabled.
|
@pcwalton, did this hang happen on 32-bit OSX? I was under the impression that, for x86_64, |
Use `objc_msgSend_fpret` for `backingStoreFactor`.
|
@SSheldon It was on 64-bit OS X. |
|
@pcwalton, interesting! I'd like to test this in my own ObjC crate, any info about the case where you were seeing weird behavior? msg_send was just always returning the wrong value? Or maybe was this when messaging nil? |
|
@SSheldon What I saw was |
|
@pcwalton and @bjz, I don't think extern crate cocoa;
use std::mem;
use cocoa::base::{class, id, msg_send, objc_msgSend, SEL, selector};
fn main() {
unsafe {
let number = msg_send()(class("NSNumber"), selector("numberWithDouble:"), 3.14f64);
let f: extern fn(id, SEL, ...) -> f64 = mem::transmute(objc_msgSend);
let value = f(number, selector("doubleValue"));
assert!(value == 3.14);
}
}This fails when compiled with optimizations. However, if you change the type of I think the true problem here is that this crate treats |
|
Here's how the assembly changes when you switch from movq %rax, -32(%rbp)
leaq -32(%rbp), %rdi
callq __ZN4base8selector20hdba17a2bd7f3a148eHeE
- movq %rax, %rcx
- xorl %eax, %eax
movq %rbx, %rdi
- movq %rcx, %rsi
+ movq %rax, %rsi
callq _objc_msgSend
- movd %rax, %xmm0
ucomisd LCPI0_0(%rip), %xmm0
jne LBB0_10
jnp LBB0_11(I'm not much of an assembly programmer, so I'm not sure why this fixes the bug, just thought it might be informative.) |
This mistake led to a bizarre chain reaction in Servo that ultimately
led to a hang only when optimization was enabled.
r? @bjz