ruby-changes:53736
From: samuel <ko1@a...>
Date: Sat, 24 Nov 2018 20:35:36 +0900 (JST)
Subject: [ruby-changes:53736] samuel:r65952 (trunk): Change Makefile rule for assembly to use .S rather than .s
samuel 2018-11-24 20:35:29 +0900 (Sat, 24 Nov 2018) New Revision: 65952 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65952 Log: Change Makefile rule for assembly to use .S rather than .s It is more conventional to use compiler to pre-process and assemble the `.S` file rather than forcing Makefile to use `.s`. Added files: trunk/coroutine/amd64/Context.S trunk/coroutine/arm32/Context.S trunk/coroutine/arm64/Context.S trunk/coroutine/win64/Context.S trunk/coroutine/x86/Context.S trunk/ia64.S Removed files: trunk/coroutine/amd64/Context.s trunk/coroutine/arm32/Context.s trunk/coroutine/arm64/Context.s trunk/coroutine/win64/Context.s trunk/coroutine/x86/Context.s trunk/ia64.s Modified files: trunk/Makefile.in Index: ia64.s =================================================================== --- ia64.s (revision 65951) +++ ia64.s (nonexistent) @@ -1,42 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/ia64.s#L0 -// rb_ia64_flushrs and rb_ia64_bsp is written in IA64 assembly language -// because Intel Compiler for IA64 doesn't support inline assembly. -// -// This file is based on following C program compiled by gcc. -// -// void rb_ia64_flushrs(void) { __builtin_ia64_flushrs(); } -// void *rb_ia64_bsp(void) { return __builtin_ia64_bsp(); } -// -// Note that rb_ia64_flushrs and rb_ia64_bsp works in its own stack frame. -// It's because BSP is updated by br.call/brl.call (not alloc instruction). -// So rb_ia64_flushrs flushes stack frames including caller's one. -// rb_ia64_bsp returns the address next to caller's register stack frame. -// -// See also -// Intel Itanium Architecture Software Developer's Manual -// Volume 2: System Architecture. -// - .file "ia64.c" - .text - .align 16 - .global rb_ia64_flushrs# - .proc rb_ia64_flushrs# -rb_ia64_flushrs: - .prologue - .body - flushrs - ;; - nop.i 0 - br.ret.sptk.many b0 - .endp rb_ia64_flushrs# - .align 16 - .global rb_ia64_bsp# - .proc rb_ia64_bsp# -rb_ia64_bsp: - .prologue - .body - nop.m 0 - ;; - mov r8 = ar.bsp - br.ret.sptk.many b0 - .endp rb_ia64_bsp# - .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13)" Property changes on: ia64.s ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: coroutine/arm32/Context.s =================================================================== --- coroutine/arm32/Context.s (revision 65951) +++ coroutine/arm32/Context.s (nonexistent) @@ -1,14 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/arm32/Context.s#L0 -## -## This file is part of the "Coroutine" project and released under the MIT License. -## -## Created by Samuel Williams on 10/5/2018. -## Copyright, 2018, by Samuel Williams. All rights reserved. -## - -.text - -.globl coroutine_transfer -coroutine_transfer: - stmia r1!, {r4-r11,sp,lr} - ldmia r0!, {r4-r11,sp,pc} - bx lr Index: coroutine/x86/Context.s =================================================================== --- coroutine/x86/Context.s (revision 65951) +++ coroutine/x86/Context.s (nonexistent) @@ -1,39 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/x86/Context.s#L0 -## -## This file is part of the "Coroutine" project and released under the MIT License. -## -## Created by Samuel Williams on 3/11/2018. -## Copyright, 2018, by Samuel Williams. All rights reserved. -## - -.text - -.globl coroutine_transfer -coroutine_transfer: - -# For older linkers -.globl _coroutine_transfer -_coroutine_transfer: - - # Save caller registers - pushl %ebp - pushl %ebx - pushl %edi - pushl %esi - - # Save caller stack pointer - movl %esp, (%ecx) - - # Restore callee stack pointer - movl (%edx), %esp - - # Restore callee stack - popl %esi - popl %edi - popl %ebx - popl %ebp - - # Save the first argument as the return value - movl %ecx, %eax - - # Jump to the address on the stack - ret Property changes on: coroutine/x86/Context.s ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: coroutine/win64/Context.s =================================================================== --- coroutine/win64/Context.s (revision 65951) +++ coroutine/win64/Context.s (nonexistent) @@ -1,77 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/win64/Context.s#L0 -## -## This file is part of the "Coroutine" project and released under the MIT License. -## -## Created by Samuel Williams on 4/11/2018. -## Copyright, 2018, by Samuel Williams. All rights reserved. -## - -.text - -.globl coroutine_transfer -coroutine_transfer: - # Save the thread information block: - pushq %gs:8 - pushq %gs:16 - - # Save caller registers: - pushq %rbp - pushq %rbx - pushq %rdi - pushq %rsi - pushq %r12 - pushq %r13 - pushq %r14 - pushq %r15 - - movaps %xmm15, -168(%rsp) - movaps %xmm14, -152(%rsp) - movaps %xmm13, -136(%rsp) - movaps %xmm12, -120(%rsp) - movaps %xmm11, -104(%rsp) - movaps %xmm10, -88(%rsp) - movaps %xmm9, -72(%rsp) - movaps %xmm8, -56(%rsp) - movaps %xmm7, -40(%rsp) - movaps %xmm6, -24(%rsp) - - # Save caller stack pointer: - mov %rsp, (%rcx) - - # Restore callee stack pointer: - mov (%rdx), %rsp - - movaps -24(%rsp), %xmm6 - movaps -40(%rsp), %xmm7 - movaps -56(%rsp), %xmm8 - movaps -72(%rsp), %xmm9 - movaps -88(%rsp), %xmm10 - movaps -104(%rsp), %xmm11 - movaps -120(%rsp), %xmm12 - movaps -136(%rsp), %xmm13 - movaps -152(%rsp), %xmm14 - movaps -168(%rsp), %xmm15 - - # Restore callee stack: - popq %r15 - popq %r14 - popq %r13 - popq %r12 - popq %rsi - popq %rdi - popq %rbx - popq %rbp - - # Restore the thread information block: - popq %gs:16 - popq %gs:8 - - # Put the first argument into the return value: - mov %rcx, %rax - - # We pop the return address and jump to it: - ret - -.globl coroutine_trampoline -coroutine_trampoline: - # Do not remove this. This forces 16-byte alignment when entering the coroutine. - ret Property changes on: coroutine/win64/Context.s ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: coroutine/arm64/Context.s =================================================================== --- coroutine/arm64/Context.s (revision 65951) +++ coroutine/arm64/Context.s (nonexistent) @@ -1,59 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/arm64/Context.s#L0 -## -## This file is part of the "Coroutine" project and released under the MIT License. -## -## Created by Samuel Williams on 10/5/2018. -## Copyright, 2018, by Samuel Williams. All rights reserved. -## - -.text -.align 2 - -.global coroutine_transfer -coroutine_transfer: - - # Make space on the stack for caller registers - sub sp, sp, 0xb0 - - # Save caller registers - stp d8, d9, [sp, 0x00] - stp d10, d11, [sp, 0x10] - stp d12, d13, [sp, 0x20] - stp d14, d15, [sp, 0x30] - stp x19, x20, [sp, 0x40] - stp x21, x22, [sp, 0x50] - stp x23, x24, [sp, 0x60] - stp x25, x26, [sp, 0x70] - stp x27, x28, [sp, 0x80] - stp x29, x30, [sp, 0x90] - - # Save return address - str x30, [sp, 0xa0] - - # Save stack pointer to x0 (first argument) - mov x2, sp - str x2, [x0, 0] - - # Load stack pointer from x1 (second argument) - ldr x3, [x1, 0] - mov sp, x3 - - # Restore caller registers - ldp d8, d9, [sp, 0x00] - ldp d10, d11, [sp, 0x10] - ldp d12, d13, [sp, 0x20] - ldp d14, d15, [sp, 0x30] - ldp x19, x20, [sp, 0x40] - ldp x21, x22, [sp, 0x50] - ldp x23, x24, [sp, 0x60] - ldp x25, x26, [sp, 0x70] - ldp x27, x28, [sp, 0x80] - ldp x29, x30, [sp, 0x90] - - # Load return address into x4 - ldr x4, [sp, 0xa0] - - # Pop stack frame - add sp, sp, 0xb0 - - # Jump to return address (in x4) - ret x4 Index: coroutine/amd64/Context.s =================================================================== --- coroutine/amd64/Context.s (revision 65951) +++ coroutine/amd64/Context.s (nonexistent) @@ -1,42 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/amd64/Context.s#L0 -## -## This file is part of the "Coroutine" project and released under the MIT License. -## -## Created by Samuel Williams on 10/5/2018. -## Copyright, 2018, by Samuel Williams. All rights reserved. -## - -.text - -# For older linkers -.globl _coroutine_transfer -_coroutine_transfer: - -.globl coroutine_transfer -coroutine_transfer: - # Save caller state - pushq %rbp - pushq %rbx - pushq %r12 - pushq %r13 - pushq %r14 - pushq %r15 - - # Save caller stack pointer - movq %rsp, (%rdi) - - # Restore callee stack pointer - movq (%rsi), %rsp - - # Restore callee stack - popq %r15 - popq %r14 - popq %r13 - popq %r12 - popq %rbx - popq %rbp - - # Put the first argument into the return value - movq %rdi, %rax - - # We pop the return address and jump to it - ret Property changes on: coroutine/amd64/Context.s ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -LF \ No newline at end of property Index: Makefile.in =================================================================== --- Makefile.in (revision 65951) +++ Makefile.in (revision 65952) @@ -213,7 +213,7 @@ DTRACE_REBUILD= @DTRACE_REBUILD@ https://github.com/ruby/ruby/blob/trunk/Makefile.in#L213 DTRACE_GLOMMED_OBJ = $(DTRACE_REBUILD:yes=ruby-glommed.$(OBJEXT)) OBJEXT = @OBJEXT@ -ASMEXT = s +ASMEXT = S SOEXT = @SOEXT@ DLEXT = @DLEXT@ MANTYPE = @MANTYPE@ Index: coroutine/arm32/Context.S =================================================================== --- coroutine/arm32/Context.S (nonexistent) +++ coroutine/arm32/Context.S (revision 65952) @@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/arm32/Context.S#L1 +## +## This file is part of the "Coroutine" project and released under the MIT License. +## +## Created by Samuel Williams on 10/5/2018. +## Copyright, 2018, by Samuel Williams. All rights reserved. +## + +.text + +.globl coroutine_transfer +coroutine_transfer: + stmia r1!, {r4-r11,sp,lr} + ldmia r0!, {r4-r11,sp,pc} + bx lr Index: coroutine/x86/Context.S =================================================================== --- coroutine/x86/Context.S (nonexistent) +++ coroutine/x86/Context.S (revision 65952) @@ -0,0 +1,39 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/x86/Context.S#L1 +## +## This file is part of the "Coroutine" project and released under the MIT License. +## +## Created by Samuel Williams on 3/11/2018. +## Copyright, 2018, by Samuel Williams. All rights reserved. +## + +.text + +.globl coroutine_transfer +coroutine_transfer: + +# For older linkers +.globl _coroutine_transfer +_coroutine_transfer: + + # Save caller registers + pushl %ebp + pushl %ebx + pushl %edi + pushl %esi + + # Save caller stack pointer + movl %esp, (%ecx) + + # Restore callee stack pointer + movl (%edx), %esp + + # Restore callee stack + popl %esi + popl %edi + popl %ebx + popl %ebp + + # Save the first argument as the return value + movl %ecx, %eax + + # Jump to the address on the stack + ret Property changes on: coroutine/x86/Context.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: coroutine/win64/Context.S =================================================================== --- coroutine/win64/Context.S (nonexistent) +++ coroutine/win64/Context.S (revision 65952) @@ -0,0 +1,77 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/win64/Context.S#L1 +## +## This file is part of the "Coroutine" project and released under the MIT License. +## +## Created by Samuel Williams on 4/11/2018. +## Copyright, 2018, by Samuel Williams. All rights reserved. +## + +.text + +.globl coroutine_transfer +coroutine_transfer: + # Save the thread information block: + pushq %gs:8 + pushq %gs:16 + + # Save caller registers: + pushq %rbp + pushq %rbx + pushq %rdi + pushq %rsi + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + + movaps %xmm15, -168(%rsp) + movaps %xmm14, -152(%rsp) + movaps %xmm13, -136(%rsp) + movaps %xmm12, -120(%rsp) + movaps %xmm11, -104(%rsp) + movaps %xmm10, -88(%rsp) + movaps %xmm9, -72(%rsp) + movaps %xmm8, -56(%rsp) + movaps %xmm7, -40(%rsp) + movaps %xmm6, -24(%rsp) + + # Save caller stack pointer: + mov %rsp, (%rcx) + + # Restore callee stack pointer: + mov (%rdx), %rsp + + movaps -24(%rsp), %xmm6 + movaps -40(%rsp), %xmm7 + movaps -56(%rsp), %xmm8 + movaps -72(%rsp), %xmm9 + movaps -88(%rsp), %xmm10 + movaps -104(%rsp), %xmm11 + movaps -120(%rsp), %xmm12 + movaps -136(%rsp), %xmm13 + movaps -152(%rsp), %xmm14 + movaps -168(%rsp), %xmm15 + + # Restore callee stack: + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %rsi + popq %rdi + popq %rbx + popq %rbp + + # Restore the thread information block: + popq %gs:16 + popq %gs:8 + + # Put the first argument into the return value: + mov %rcx, %rax + + # We pop the return address and jump to it: + ret + +.globl coroutine_trampoline +coroutine_trampoline: + # Do not remove this. This forces 16-byte alignment when entering the coroutine. + ret Property changes on: coroutine/win64/Context.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: coroutine/arm64/Context.S =================================================================== --- coroutine/arm64/Context.S (nonexistent) +++ coroutine/arm64/Context.S (revision 65952) @@ -0,0 +1,59 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/arm64/Context.S#L1 +## +## This file is part of the "Coroutine" project and released under the MIT License. +## +## Created by Samuel Williams on 10/5/2018. +## Copyright, 2018, by Samuel Williams. All rights reserved. +## + +.text +.align 2 + +.global coroutine_transfer +coroutine_transfer: + + # Make space on the stack for caller registers + sub sp, sp, 0xb0 + + # Save caller registers + stp d8, d9, [sp, 0x00] + stp d10, d11, [sp, 0x10] + stp d12, d13, [sp, 0x20] + stp d14, d15, [sp, 0x30] + stp x19, x20, [sp, 0x40] + stp x21, x22, [sp, 0x50] + stp x23, x24, [sp, 0x60] + stp x25, x26, [sp, 0x70] + stp x27, x28, [sp, 0x80] + stp x29, x30, [sp, 0x90] + + # Save return address + str x30, [sp, 0xa0] + + # Save stack pointer to x0 (first argument) + mov x2, sp + str x2, [x0, 0] + + # Load stack pointer from x1 (second argument) + ldr x3, [x1, 0] + mov sp, x3 + + # Restore caller registers + ldp d8, d9, [sp, 0x00] + ldp d10, d11, [sp, 0x10] + ldp d12, d13, [sp, 0x20] + ldp d14, d15, [sp, 0x30] + ldp x19, x20, [sp, 0x40] + ldp x21, x22, [sp, 0x50] + ldp x23, x24, [sp, 0x60] + ldp x25, x26, [sp, 0x70] + ldp x27, x28, [sp, 0x80] + ldp x29, x30, [sp, 0x90] + + # Load return address into x4 + ldr x4, [sp, 0xa0] + + # Pop stack frame + add sp, sp, 0xb0 + + # Jump to return address (in x4) + ret x4 Index: coroutine/amd64/Context.S =================================================================== --- coroutine/amd64/Context.S (nonexistent) +++ coroutine/amd64/Context.S (revision 65952) @@ -0,0 +1,42 @@ https://github.com/ruby/ruby/blob/trunk/coroutine/amd64/Context.S#L1 +## +## This file is part of the "Coroutine" project and released under the MIT License. +## +## Created by Samuel Williams on 10/5/2018. +## Copyright, 2018, by Samuel Williams. All rights reserved. +## + +.text + +# For older linkers +.globl _coroutine_transfer +_coroutine_transfer: + +.globl coroutine_transfer +coroutine_transfer: + # Save caller state + pushq %rbp + pushq %rbx + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 + + # Save caller stack pointer + movq %rsp, (%rdi) + + # Restore callee stack pointer + movq (%rsi), %rsp + + # Restore callee stack + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %rbx + popq %rbp + + # Put the first argument into the return value + movq %rdi, %rax + + # We pop the return address and jump to it + ret Property changes on: coroutine/amd64/Context.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: ia64.S =================================================================== --- ia64.S (nonexistent) +++ ia64.S (revision 65952) @@ -0,0 +1,42 @@ https://github.com/ruby/ruby/blob/trunk/ia64.S#L1 +// rb_ia64_flushrs and rb_ia64_bsp is written in IA64 assembly language +// because Intel Compiler for IA64 doesn't support inline assembly. +// +// This file is based on following C program compiled by gcc. +// +// void rb_ia64_flushrs(void) { __builtin_ia64_flushrs(); } +// void *rb_ia64_bsp(void) { return __builtin_ia64_bsp(); } +// +// Note that rb_ia64_flushrs and rb_ia64_bsp works in its own stack frame. +// It's because BSP is updated by br.call/brl.call (not alloc instruction). +// So rb_ia64_flushrs flushes stack frames including caller's one. +// rb_ia64_bsp returns the address next to caller's register stack frame. +// +// See also +// Intel Itanium Architecture Software Developer's Manual +// Volume 2: System Architecture. +// + .file "ia64.c" + .text + .align 16 + .global rb_ia64_flushrs# + .proc rb_ia64_flushrs# +rb_ia64_flushrs: + .prologue + .body + flushrs + ;; + nop.i 0 + br.ret.sptk.many b0 + .endp rb_ia64_flushrs# + .align 16 + .global rb_ia64_bsp# + .proc rb_ia64_bsp# +rb_ia64_bsp: + .prologue + .body + nop.m 0 + ;; + mov r8 = ar.bsp + br.ret.sptk.many b0 + .endp rb_ia64_bsp# + .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-13)" Property changes on: ia64.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/