Skip to content

Commit 342cc46

Browse files
committed
fix longdouble ulong->double unconditionally
use gcc style asm
1 parent aa55ec5 commit 342cc46

File tree

3 files changed

+66
-68
lines changed

3 files changed

+66
-68
lines changed

dmd/root/longdouble.d

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,14 @@ void ld_setull(longdouble_soft* pthis, ulong d)
342342
{
343343
// emulator accuracy not good enough when running on Windows on ARM,
344344
// so avoid chopping off small numbers
345-
version(LDC)
345+
if (!(d & (1L << 63)))
346346
{
347-
if (!(d & (1L << 63)))
347+
asm nothrow @nogc pure @trusted
348348
{
349-
asm nothrow @nogc pure @trusted
350-
{
351-
fild qword ptr d;
352-
}
353-
mixin(fstp_parg!("pthis"));
354-
return;
349+
fild qword ptr d;
355350
}
351+
mixin(fstp_parg!("pthis"));
352+
return;
356353
}
357354
d ^= (1L << 63);
358355
auto pTwoPow63 = &twoPow63;

runtime/druntime/src/core/thread/fiber.d

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -363,59 +363,59 @@ private
363363
else version (AsmAArch64_Windows)
364364
{
365365
pragma(LDC_never_inline);
366-
__asm(
366+
asm pure nothrow @nogc
367+
{
367368
`// save current stack state (similar to posix version in threadasm.S)
368-
stp x19, x20, [sp, #-16]!
369-
stp x21, x22, [sp, #-16]!
370-
stp x23, x24, [sp, #-16]!
371-
stp x25, x26, [sp, #-16]!
372-
stp x27, x28, [sp, #-16]!
373-
stp fp, lr, [sp, #-16]!
374-
mov x19, sp // no need to scan FP registers, so snapshot sp here
375-
376-
stp d8, d9, [sp, #-16]!
377-
stp d10, d11, [sp, #-16]!
378-
stp d12, d13, [sp, #-16]!
379-
stp d14, d15, [sp, #-16]!
380-
381-
ldr x20, [x18, #8] // read stack range from TEB
382-
ldr x21, [x18, #16]
383-
stp x20, x21, [sp, #-16]!
384-
385-
ldr x20, [x18, #0x1478] // read Deallocation Stack
386-
ldr w21, [x18, #0x1748] // read GuaranteedStackBytes
387-
stp x20, x21, [sp, #-16]!
369+
stp x19, x20, [sp, #-16]!;
370+
stp x21, x22, [sp, #-16]!;
371+
stp x23, x24, [sp, #-16]!;
372+
stp x25, x26, [sp, #-16]!;
373+
stp x27, x28, [sp, #-16]!;
374+
stp fp, lr, [sp, #-16]!;
375+
mov x19, sp; // no need to scan FP registers, so snapshot sp here
376+
377+
stp d8, d9, [sp, #-16]!;
378+
stp d10, d11, [sp, #-16]!;
379+
stp d12, d13, [sp, #-16]!;
380+
stp d14, d15, [sp, #-16]!;
381+
382+
ldr x20, [x18, #8]; // read stack range from TEB
383+
ldr x21, [x18, #16];
384+
stp x20, x21, [sp, #-16]!;
385+
386+
ldr x20, [x18, #0x1478]; // read Deallocation Stack
387+
ldr w21, [x18, #0x1748]; // read GuaranteedStackBytes
388+
stp x20, x21, [sp, #-16]!;
388389
389390
// store oldp
390-
str x19, [x0]
391+
str x19, [x0];
391392
// load newp to begin context switch
392-
sub x1, x1, #6*16
393-
mov sp, x1
393+
sub x1, x1, #6*16;
394+
mov sp, x1;
394395
395-
ldp x20, x21, [sp], #16 // restore Deallocation/GuaranteedStackBytes
396-
str x20, [x18, #0x1478]
397-
str w21, [x18, #0x1748] // word only
396+
ldp x20, x21, [sp], #16; // restore Deallocation/GuaranteedStackBytes
397+
str x20, [x18, #0x1478];
398+
str w21, [x18, #0x1748]; // word only
398399
399-
ldp x20, x21, [sp], #16 // restore stack range
400-
str x20, [x18, #8]
401-
str x21, [x18, #16]
400+
ldp x20, x21, [sp], #16; // restore stack range
401+
str x20, [x18, #8];
402+
str x21, [x18, #16];
402403
403404
// load saved state from new stack
404-
ldp d14, d15, [sp], #16
405-
ldp d12, d13, [sp], #16
406-
ldp d10, d11, [sp], #16
407-
ldp d8, d9, [sp], #16
408-
409-
ldp fp, lr, [sp], #16
410-
ldp x27, x28, [sp], #16
411-
ldp x25, x26, [sp], #16
412-
ldp x23, x24, [sp], #16
413-
ldp x21, x22, [sp], #16
414-
ldp x19, x20, [sp], #16
415-
416-
ret`,
417-
""
418-
);
405+
ldp d14, d15, [sp], #16;
406+
ldp d12, d13, [sp], #16;
407+
ldp d10, d11, [sp], #16;
408+
ldp d8, d9, [sp], #16;
409+
410+
ldp fp, lr, [sp], #16;
411+
ldp x27, x28, [sp], #16;
412+
ldp x25, x26, [sp], #16;
413+
ldp x23, x24, [sp], #16;
414+
ldp x21, x22, [sp], #16;
415+
ldp x19, x20, [sp], #16;
416+
417+
ret;`;
418+
}
419419
}
420420
else
421421
static assert(false);

runtime/druntime/src/ldc/eh_msvc.d

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -542,27 +542,28 @@ void msvc_eh_terminate() nothrow @naked
542542
}
543543
else version (AArch64)
544544
{
545-
__asm(`
546-
bl _D3ldc7eh_msvc21tlsUncaughtExceptionsFNbZm
547-
cmp w0, #0
548-
ble 1f
545+
asm pure nothrow @nogc
546+
{`
547+
bl _D3ldc7eh_msvc21tlsUncaughtExceptionsFNbZm;
548+
cmp w0, #0;
549+
ble 1f;
549550
550551
// hacking into the call chain to return EXCEPTION_EXECUTE_HANDLER
551552
// as the return value of __FrameUnwindFilter so that
552553
// __FrameUnwindToState continues with the next unwind block
553-
ldr x0, [fp] // __FrameUnwindFilter's fp
554-
mov sp, x0
555-
mov w0, #1 // return EXCEPTION_EXECUTE_HANDLER
556-
ldp fp,lr,[sp],#16
557-
ldp x19,x20,[sp],#0x10
558-
autibsp // uses lr,sp and x19 as input to hash
559-
ret
554+
ldr x0, [fp]; // __FrameUnwindFilter's fp
555+
mov sp, x0;
556+
mov w0, #1; // return EXCEPTION_EXECUTE_HANDLER
557+
ldp fp,lr,[sp],#16;
558+
ldp x19,x20,[sp],#0x10;
559+
autibsp; // uses lr,sp and x19 as input to hash
560+
ret;
560561
561562
1:
562-
ldp fp,lr,[sp],#16
563-
ret`,
564-
"~{memory},~{x0},~{x19},~{x20}"
565-
);
563+
ldp fp,lr,[sp],#16;
564+
ret;`
565+
: : : "x0", "x19", "x20";
566+
}
566567
}
567568
}
568569

0 commit comments

Comments
 (0)