2009-06-10 12:53:07 -06:00
|
|
|
// Inferno's libkern/vlop-arm.s
|
|
|
|
// http://code.google.com/p/inferno-os/source/browse/libkern/vlop-arm.s
|
|
|
|
//
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
// Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved.
|
|
|
|
// Portions Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
2013-08-01 18:07:01 -06:00
|
|
|
#include "zasm_GOOS_GOARCH.h"
|
2014-09-04 21:05:18 -06:00
|
|
|
#include "textflag.h"
|
2013-08-01 18:07:01 -06:00
|
|
|
|
2009-06-10 12:53:07 -06:00
|
|
|
arg=0
|
|
|
|
|
|
|
|
/* replaced use of R10 by R11 because the former can be the data segment base register */
|
|
|
|
|
2013-08-07 13:20:05 -06:00
|
|
|
TEXT _mulv(SB), NOSPLIT, $0
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW l0+0(FP), R2 /* l0 */
|
|
|
|
MOVW h0+4(FP), R11 /* h0 */
|
|
|
|
MOVW l1+8(FP), R4 /* l1 */
|
|
|
|
MOVW h1+12(FP), R5 /* h1 */
|
2012-06-02 14:03:09 -06:00
|
|
|
MULLU R4, R2, (R7,R6)
|
|
|
|
MUL R11, R4, R8
|
2009-06-10 12:53:07 -06:00
|
|
|
ADD R8, R7
|
2012-06-02 14:03:09 -06:00
|
|
|
MUL R2, R5, R8
|
2009-06-10 12:53:07 -06:00
|
|
|
ADD R8, R7
|
cmd/cc, runtime: convert C compilers to use Go calling convention
To date, the C compilers and Go compilers differed only in how
values were returned from functions. This made it difficult to call
Go from C or C from Go if return values were involved. It also made
assembly called from Go and assembly called from C different.
This CL changes the C compiler to use the Go conventions, passing
results on the stack, after the arguments.
[Exception: this does not apply to C ... functions, because you can't
know where on the stack the arguments end.]
By doing this, the CL makes it possible to rewrite C functions into Go
one at a time, without worrying about which languages call that
function or which languages it calls.
This CL also updates all the assembly files in package runtime to use
the new conventions. Argument references of the form 40(SP) have
been rewritten to the form name+10(FP) instead, and there are now
Go func prototypes for every assembly function called from C or Go.
This means that 'go vet runtime' checks effectively every assembly
function, and go vet's output was used to automate the bulk of the
conversion.
Some functions, like seek and nsec on Plan 9, needed to be rewritten.
Many assembly routines called from C were reading arguments
incorrectly, using MOVL instead of MOVQ or vice versa, especially on
the less used systems like openbsd.
These were found by go vet and have been corrected too.
If we're lucky, this may reduce flakiness on those systems.
Tested on:
darwin/386
darwin/amd64
linux/arm
linux/386
linux/amd64
If this breaks another system, the bug is almost certainly in the
sys_$GOOS_$GOARCH.s file, since the rest of the CL is tested
by the combination of the above systems.
LGTM=dvyukov, iant
R=golang-codereviews, 0intro, dave, alex.brainman, dvyukov, iant
CC=golang-codereviews, josharian, r
https://golang.org/cl/135830043
2014-08-27 09:32:17 -06:00
|
|
|
MOVW R6, ret_lo+16(FP)
|
|
|
|
MOVW R7, ret_hi+20(FP)
|
2009-06-10 12:53:07 -06:00
|
|
|
RET
|
|
|
|
|
2009-12-17 17:08:42 -07:00
|
|
|
// trampoline for _sfloat2. passes LR as arg0 and
|
2010-04-15 03:43:49 -06:00
|
|
|
// saves registers R0-R13 and CPSR on the stack. R0-R12 and CPSR flags can
|
|
|
|
// be changed by _sfloat2.
|
2014-08-27 20:41:32 -06:00
|
|
|
TEXT _sfloat(SB), NOSPLIT, $68-0 // 4 arg + 14*4 saved regs + cpsr + return value
|
2009-12-17 17:08:42 -07:00
|
|
|
MOVW R14, 4(R13)
|
|
|
|
MOVW R0, 8(R13)
|
|
|
|
MOVW $12(R13), R0
|
2010-04-15 03:43:49 -06:00
|
|
|
MOVM.IA.W [R1-R12], (R0)
|
2014-08-27 20:41:32 -06:00
|
|
|
MOVW $72(R13), R1 // correct for frame size
|
2010-04-15 03:43:49 -06:00
|
|
|
MOVW R1, 60(R13)
|
|
|
|
WORD $0xe10f1000 // mrs r1, cpsr
|
|
|
|
MOVW R1, 64(R13)
|
2013-08-01 18:07:01 -06:00
|
|
|
// Disable preemption of this goroutine during _sfloat2 by
|
|
|
|
// m->locks++ and m->locks-- around the call.
|
|
|
|
// Rescheduling this goroutine may cause the loss of the
|
|
|
|
// contents of the software floating point registers in
|
|
|
|
// m->freghi, m->freglo, m->fflag, if the goroutine is moved
|
|
|
|
// to a different m or another goroutine runs on this m.
|
|
|
|
// Rescheduling at ordinary function calls is okay because
|
|
|
|
// all registers are caller save, but _sfloat2 and the things
|
|
|
|
// that it runs are simulating the execution of individual
|
|
|
|
// program instructions, and those instructions do not expect
|
|
|
|
// the floating point registers to be lost.
|
|
|
|
// An alternative would be to move the software floating point
|
|
|
|
// registers into G, but they do not need to be kept at the
|
|
|
|
// usual places a goroutine reschedules (at function calls),
|
|
|
|
// so it would be a waste of 132 bytes per G.
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW g_m(g), R8
|
|
|
|
MOVW m_locks(R8), R1
|
2013-08-01 18:07:01 -06:00
|
|
|
ADD $1, R1
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW R1, m_locks(R8)
|
2014-04-03 13:39:48 -06:00
|
|
|
MOVW $1, R1
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW R1, m_softfloat(R8)
|
2010-11-10 16:10:19 -07:00
|
|
|
BL runtime·_sfloat2(SB)
|
2014-08-27 20:41:32 -06:00
|
|
|
MOVW 68(R13), R0
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW g_m(g), R8
|
|
|
|
MOVW m_locks(R8), R1
|
2013-08-01 18:07:01 -06:00
|
|
|
SUB $1, R1
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW R1, m_locks(R8)
|
2014-04-03 13:39:48 -06:00
|
|
|
MOVW $0, R1
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
MOVW R1, m_softfloat(R8)
|
2009-12-17 17:08:42 -07:00
|
|
|
MOVW R0, 0(R13)
|
2010-04-15 03:43:49 -06:00
|
|
|
MOVW 64(R13), R1
|
|
|
|
WORD $0xe128f001 // msr cpsr_f, r1
|
2009-12-17 17:08:42 -07:00
|
|
|
MOVW $12(R13), R0
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 09:54:39 -06:00
|
|
|
// Restore R1-R12, R0.
|
|
|
|
MOVM.IA.W (R0), [R1-R12]
|
2009-12-17 17:08:42 -07:00
|
|
|
MOVW 8(R13), R0
|
|
|
|
RET
|
|
|
|
|
2014-09-05 12:58:54 -06:00
|
|
|
// trampoline for _sfloat2 panic.
|
|
|
|
// _sfloat2 instructs _sfloat to return here.
|
|
|
|
// We need to push a fake saved LR onto the stack,
|
|
|
|
// load the signal fault address into LR, and jump
|
|
|
|
// to the real sigpanic.
|
|
|
|
// This simulates what sighandler does for a memory fault.
|
|
|
|
TEXT _sfloatpanic(SB),NOSPLIT,$-4
|
|
|
|
MOVW $0, R0
|
|
|
|
MOVW.W R0, -4(R13)
|
|
|
|
MOVW g_sigpc(g), LR
|
|
|
|
B runtime·sigpanic(SB)
|
|
|
|
|
2012-10-20 02:40:19 -06:00
|
|
|
// func udiv(n, d uint32) (q, r uint32)
|
|
|
|
// Reference:
|
|
|
|
// Sloss, Andrew et. al; ARM System Developer's Guide: Designing and Optimizing System Software
|
|
|
|
// Morgan Kaufmann; 1 edition (April 8, 2004), ISBN 978-1558608740
|
|
|
|
q = 0 // input d, output q
|
|
|
|
r = 1 // input n, output r
|
|
|
|
s = 2 // three temporary variables
|
2013-05-29 13:03:52 -06:00
|
|
|
M = 3
|
2012-10-20 02:40:19 -06:00
|
|
|
a = 11
|
2013-09-16 12:04:45 -06:00
|
|
|
// Be careful: R(a) == R11 will be used by the linker for synthesized instructions.
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
TEXT udiv<>(SB),NOSPLIT,$-4
|
2012-10-20 02:40:19 -06:00
|
|
|
CLZ R(q), R(s) // find normalizing shift
|
|
|
|
MOVW.S R(q)<<R(s), R(a)
|
2013-09-16 12:04:45 -06:00
|
|
|
MOVW $fast_udiv_tab<>-64(SB), R(M)
|
2014-07-10 13:14:49 -06:00
|
|
|
ADD.NE R(a)>>25, R(M), R(a) // index by most significant 7 bits of divisor
|
|
|
|
MOVBU.NE (R(a)), R(a)
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
SUB.S $7, R(s)
|
2013-05-29 13:03:52 -06:00
|
|
|
RSB $0, R(q), R(M) // M = -q
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW.PL R(a)<<R(s), R(q)
|
|
|
|
|
|
|
|
// 1st Newton iteration
|
2013-05-29 13:03:52 -06:00
|
|
|
MUL.PL R(M), R(q), R(a) // a = -q*d
|
2012-10-20 02:40:19 -06:00
|
|
|
BMI udiv_by_large_d
|
|
|
|
MULAWT R(a), R(q), R(q), R(q) // q approx q-(q*q*d>>32)
|
2013-05-29 13:03:52 -06:00
|
|
|
TEQ R(M)->1, R(M) // check for d=0 or d=1
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
// 2nd Newton iteration
|
2013-05-29 13:03:52 -06:00
|
|
|
MUL.NE R(M), R(q), R(a)
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW.NE $0, R(s)
|
|
|
|
MULAL.NE R(q), R(a), (R(q),R(s))
|
|
|
|
BEQ udiv_by_0_or_1
|
|
|
|
|
|
|
|
// q now accurate enough for a remainder r, 0<=r<3*d
|
|
|
|
MULLU R(q), R(r), (R(q),R(s)) // q = (r * q) >> 32
|
2013-05-29 13:03:52 -06:00
|
|
|
ADD R(M), R(r), R(r) // r = n - d
|
|
|
|
MULA R(M), R(q), R(r), R(r) // r = n - (q+1)*d
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
// since 0 <= n-q*d < 3*d; thus -d <= r < 2*d
|
2013-05-29 13:03:52 -06:00
|
|
|
CMN R(M), R(r) // t = r-d
|
|
|
|
SUB.CS R(M), R(r), R(r) // if (t<-d || t>=0) r=r+d
|
2012-10-20 02:40:19 -06:00
|
|
|
ADD.CC $1, R(q)
|
2013-05-29 13:03:52 -06:00
|
|
|
ADD.PL R(M)<<1, R(r)
|
2012-10-20 02:40:19 -06:00
|
|
|
ADD.PL $2, R(q)
|
2013-09-16 12:04:45 -06:00
|
|
|
RET
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
udiv_by_large_d:
|
|
|
|
// at this point we know d>=2^(31-6)=2^25
|
|
|
|
SUB $4, R(a), R(a)
|
|
|
|
RSB $0, R(s), R(s)
|
|
|
|
MOVW R(a)>>R(s), R(q)
|
|
|
|
MULLU R(q), R(r), (R(q),R(s))
|
2013-05-29 13:03:52 -06:00
|
|
|
MULA R(M), R(q), R(r), R(r)
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
// q now accurate enough for a remainder r, 0<=r<4*d
|
2013-05-29 13:03:52 -06:00
|
|
|
CMN R(r)>>1, R(M) // if(r/2 >= d)
|
|
|
|
ADD.CS R(M)<<1, R(r)
|
2012-10-20 02:40:19 -06:00
|
|
|
ADD.CS $2, R(q)
|
2013-05-29 13:03:52 -06:00
|
|
|
CMN R(r), R(M)
|
|
|
|
ADD.CS R(M), R(r)
|
2012-10-20 02:40:19 -06:00
|
|
|
ADD.CS $1, R(q)
|
2013-09-16 12:04:45 -06:00
|
|
|
RET
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
udiv_by_0_or_1:
|
|
|
|
// carry set if d==1, carry clear if d==0
|
2013-09-16 12:04:45 -06:00
|
|
|
BCC udiv_by_0
|
|
|
|
MOVW R(r), R(q)
|
|
|
|
MOVW $0, R(r)
|
|
|
|
RET
|
2012-10-20 02:40:19 -06:00
|
|
|
|
2013-09-16 12:04:45 -06:00
|
|
|
udiv_by_0:
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
// The ARM toolchain expects it can emit references to DIV and MOD
|
|
|
|
// instructions. The linker rewrites each pseudo-instruction into
|
|
|
|
// a sequence that pushes two values onto the stack and then calls
|
|
|
|
// _divu, _modu, _div, or _mod (below), all of which have a 16-byte
|
|
|
|
// frame plus the saved LR. The traceback routine knows the expanded
|
|
|
|
// stack frame size at the pseudo-instruction call site, but it
|
|
|
|
// doesn't know that the frame has a non-standard layout. In particular,
|
|
|
|
// it expects to find a saved LR in the bottom word of the frame.
|
|
|
|
// Unwind the stack back to the pseudo-instruction call site, copy the
|
|
|
|
// saved LR where the traceback routine will look for it, and make it
|
|
|
|
// appear that panicdivide was called from that PC.
|
|
|
|
MOVW 0(R13), LR
|
|
|
|
ADD $20, R13
|
|
|
|
MOVW 8(R13), R1 // actual saved LR
|
|
|
|
MOVW R1, 0(R13) // expected here for traceback
|
|
|
|
B runtime·panicdivide(SB)
|
2013-09-16 12:04:45 -06:00
|
|
|
|
2014-07-10 13:14:49 -06:00
|
|
|
// var tab [64]byte
|
|
|
|
// tab[0] = 255; for i := 1; i <= 63; i++ { tab[i] = (1<<14)/(64+i) }
|
|
|
|
// laid out here as little-endian uint32s
|
|
|
|
DATA fast_udiv_tab<>+0x00(SB)/4, $0xf4f8fcff
|
|
|
|
DATA fast_udiv_tab<>+0x04(SB)/4, $0xe6eaedf0
|
|
|
|
DATA fast_udiv_tab<>+0x08(SB)/4, $0xdadde0e3
|
|
|
|
DATA fast_udiv_tab<>+0x0c(SB)/4, $0xcfd2d4d7
|
|
|
|
DATA fast_udiv_tab<>+0x10(SB)/4, $0xc5c7cacc
|
|
|
|
DATA fast_udiv_tab<>+0x14(SB)/4, $0xbcbec0c3
|
|
|
|
DATA fast_udiv_tab<>+0x18(SB)/4, $0xb4b6b8ba
|
|
|
|
DATA fast_udiv_tab<>+0x1c(SB)/4, $0xacaeb0b2
|
|
|
|
DATA fast_udiv_tab<>+0x20(SB)/4, $0xa5a7a8aa
|
|
|
|
DATA fast_udiv_tab<>+0x24(SB)/4, $0x9fa0a2a3
|
|
|
|
DATA fast_udiv_tab<>+0x28(SB)/4, $0x999a9c9d
|
|
|
|
DATA fast_udiv_tab<>+0x2c(SB)/4, $0x93949697
|
|
|
|
DATA fast_udiv_tab<>+0x30(SB)/4, $0x8e8f9092
|
|
|
|
DATA fast_udiv_tab<>+0x34(SB)/4, $0x898a8c8d
|
|
|
|
DATA fast_udiv_tab<>+0x38(SB)/4, $0x85868788
|
|
|
|
DATA fast_udiv_tab<>+0x3c(SB)/4, $0x81828384
|
|
|
|
GLOBL fast_udiv_tab<>(SB), RODATA, $64
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
// The linker will pass numerator in R(TMP), and it also
|
|
|
|
// expects the result in R(TMP)
|
|
|
|
TMP = 11
|
|
|
|
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
TEXT _divu(SB), NOSPLIT, $16
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(q), 4(R13)
|
|
|
|
MOVW R(r), 8(R13)
|
|
|
|
MOVW R(s), 12(R13)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW R(M), 16(R13)
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
MOVW R(TMP), R(r) /* numerator */
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
MOVW 0(FP), R(q) /* denominator */
|
2012-10-20 02:40:19 -06:00
|
|
|
BL udiv<>(SB)
|
|
|
|
MOVW R(q), R(TMP)
|
|
|
|
MOVW 4(R13), R(q)
|
|
|
|
MOVW 8(R13), R(r)
|
|
|
|
MOVW 12(R13), R(s)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW 16(R13), R(M)
|
2012-10-20 02:40:19 -06:00
|
|
|
RET
|
|
|
|
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
TEXT _modu(SB), NOSPLIT, $16
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(q), 4(R13)
|
|
|
|
MOVW R(r), 8(R13)
|
|
|
|
MOVW R(s), 12(R13)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW R(M), 16(R13)
|
2012-10-20 02:40:19 -06:00
|
|
|
|
|
|
|
MOVW R(TMP), R(r) /* numerator */
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
MOVW 0(FP), R(q) /* denominator */
|
2012-10-20 02:40:19 -06:00
|
|
|
BL udiv<>(SB)
|
|
|
|
MOVW R(r), R(TMP)
|
|
|
|
MOVW 4(R13), R(q)
|
|
|
|
MOVW 8(R13), R(r)
|
|
|
|
MOVW 12(R13), R(s)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW 16(R13), R(M)
|
2012-10-20 02:40:19 -06:00
|
|
|
RET
|
|
|
|
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
TEXT _div(SB),NOSPLIT,$16
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(q), 4(R13)
|
|
|
|
MOVW R(r), 8(R13)
|
|
|
|
MOVW R(s), 12(R13)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW R(M), 16(R13)
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(TMP), R(r) /* numerator */
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
MOVW 0(FP), R(q) /* denominator */
|
2012-10-20 02:40:19 -06:00
|
|
|
CMP $0, R(r)
|
|
|
|
BGE d1
|
|
|
|
RSB $0, R(r), R(r)
|
|
|
|
CMP $0, R(q)
|
|
|
|
BGE d2
|
|
|
|
RSB $0, R(q), R(q)
|
|
|
|
d0:
|
|
|
|
BL udiv<>(SB) /* none/both neg */
|
|
|
|
MOVW R(q), R(TMP)
|
2013-12-08 20:52:08 -07:00
|
|
|
B out1
|
2012-10-20 02:40:19 -06:00
|
|
|
d1:
|
|
|
|
CMP $0, R(q)
|
|
|
|
BGE d0
|
|
|
|
RSB $0, R(q), R(q)
|
|
|
|
d2:
|
|
|
|
BL udiv<>(SB) /* one neg */
|
|
|
|
RSB $0, R(q), R(TMP)
|
2013-12-08 20:52:08 -07:00
|
|
|
out1:
|
|
|
|
MOVW 4(R13), R(q)
|
|
|
|
MOVW 8(R13), R(r)
|
|
|
|
MOVW 12(R13), R(s)
|
|
|
|
MOVW 16(R13), R(M)
|
|
|
|
RET
|
2012-10-20 02:40:19 -06:00
|
|
|
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
TEXT _mod(SB),NOSPLIT,$16
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(q), 4(R13)
|
|
|
|
MOVW R(r), 8(R13)
|
|
|
|
MOVW R(s), 12(R13)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW R(M), 16(R13)
|
2012-10-20 02:40:19 -06:00
|
|
|
MOVW R(TMP), R(r) /* numerator */
|
undo CL 19810043 / 352f3b7c9664
The CL causes misc/cgo/test to fail randomly.
I suspect that the problem is the use of a division instruction
in usleep, which can be called while trying to acquire an m
and therefore cannot store the denominator in m.
The solution to that would be to rewrite the code to use a
magic multiply instead of a divide, but now we're getting
pretty far off the original code.
Go back to the original in preparation for a different,
less efficient but simpler fix.
««« original CL description
cmd/5l, runtime: make ARM integer division profiler-friendly
The implementation of division constructed non-standard
stack frames that could not be handled by the traceback
routines.
CL 13239052 left the frames non-standard but fixed them
for the specific case of a divide-by-zero panic.
A profiling signal can arrive at any time, so that fix
is not sufficient.
Change the division to store the extra argument in the M struct
instead of in a new stack slot. That keeps the frames bog standard
at all times.
Also fix a related bug in the traceback code: when starting
a traceback, the LR register should be ignored if the current
function has already allocated its stack frame and saved the
original LR on the stack. The stack copy should be used, as the
LR register may have been modified.
Combined, these make the torture test from issue 6681 pass.
Fixes #6681.
R=golang-dev, r, josharian
CC=golang-dev
https://golang.org/cl/19810043
»»»
TBR=r
CC=golang-dev
https://golang.org/cl/20350043
2013-10-31 11:18:57 -06:00
|
|
|
MOVW 0(FP), R(q) /* denominator */
|
2012-10-20 02:40:19 -06:00
|
|
|
CMP $0, R(q)
|
|
|
|
RSB.LT $0, R(q), R(q)
|
|
|
|
CMP $0, R(r)
|
|
|
|
BGE m1
|
|
|
|
RSB $0, R(r), R(r)
|
|
|
|
BL udiv<>(SB) /* neg numerator */
|
|
|
|
RSB $0, R(r), R(TMP)
|
|
|
|
B out
|
|
|
|
m1:
|
|
|
|
BL udiv<>(SB) /* pos numerator */
|
|
|
|
MOVW R(r), R(TMP)
|
|
|
|
out:
|
|
|
|
MOVW 4(R13), R(q)
|
|
|
|
MOVW 8(R13), R(r)
|
|
|
|
MOVW 12(R13), R(s)
|
2013-05-29 13:03:52 -06:00
|
|
|
MOVW 16(R13), R(M)
|
2012-10-20 02:40:19 -06:00
|
|
|
RET
|
2014-08-29 10:55:33 -06:00
|
|
|
|
|
|
|
// _mul64by32 and _div64by32 not implemented on arm
|
|
|
|
TEXT runtime·_mul64by32(SB), NOSPLIT, $0
|
|
|
|
MOVW $0, R0
|
|
|
|
MOVW (R0), R1 // crash
|
|
|
|
|
|
|
|
TEXT runtime·_div64by32(SB), NOSPLIT, $0
|
|
|
|
MOVW $0, R0
|
|
|
|
MOVW (R0), R1 // crash
|