Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Side by Side Diff: src/pkg/runtime/arm/cas5.s

Issue 4171057: code review 4171057: arm runtime: attempt to fix build by adding casp (sam a... (Closed)
Patch Set: diff -r dfbc2b3b2461 https://go.googlecode.com/hg/ Created 14 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/runtime/arm/cas6.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "arm/asm.h" 5 #include "arm/asm.h"
6 6
7 // This version works on pre v6 architectures 7 // This version works on pre v6 architectures
8 8
9 // bool cas(int32 *val, int32 old, int32 new) 9 // bool cas(int32 *val, int32 old, int32 new)
10 // Atomically: 10 // Atomically:
11 // if(*val == old){ 11 // if(*val == old){
12 // *val = new; 12 // *val = new;
13 // return 1; 13 // return 1;
14 // }else 14 // }else
15 // return 0; 15 // return 0;
16 16
17 TEXT runtime·cas(SB),7,$0 17 TEXT runtime·cas(SB),7,$0
18 MOVW 0(FP), R0 // *val 18 MOVW 0(FP), R0 // *val
19 MOVW 4(FP), R1 // old 19 MOVW 4(FP), R1 // old
20 MOVW 8(FP), R2 // new 20 MOVW 8(FP), R2 // new
21 MOVW $1, R3 21 MOVW $1, R3
22 MOVW $runtime·cas_mutex(SB), R4 22 MOVW $runtime·cas_mutex(SB), R4
23 l:
24 SWPW (R4), R3 // acquire mutex 23 SWPW (R4), R3 // acquire mutex
25 CMP $0, R3 24 CMP $0, R3
26 BNE fail0 25 BNE fail0
27 ········ 26 ········
28 MOVW (R0), R5 27 MOVW (R0), R5
29 CMP R1, R5 28 CMP R1, R5
30 BNE fail1 29 BNE fail1
31 ········ 30 ········
32 MOVW R2, (R0)········ 31 MOVW R2, (R0)········
33 MOVW R3, (R4) // release mutex 32 MOVW R3, (R4) // release mutex
34 MOVW $1, R0 33 MOVW $1, R0
35 RET 34 RET
36 fail1:·· 35 fail1:··
37 MOVW R3, (R4) // release mutex 36 MOVW R3, (R4) // release mutex
38 fail0: 37 fail0:
39 MOVW $0, R0 38 MOVW $0, R0
40 RET 39 RET
41 · 40
41 // bool casp(void **p, void *old, void *new)
42 // Atomically:
43 //» if(*p == old){
44 //» » *p = new;
45 //» » return 1;
46 //» }else
47 //» » return 0;
48
49 TEXT runtime·casp(SB),7,$0
50 » MOVW» 0(FP), R0» // *p
51 » MOVW» 4(FP), R1» // old
52 » MOVW» 8(FP), R2» // new
53 » MOVW» $1, R3
54 » MOVW» $runtime·cas_mutex(SB), R4
55 » SWPW» (R4), R3» // acquire mutex
56 » CMP» » $0, R3
57 » BNE» » failp0
58 »·······
59 » MOVW» (R0), R5
60 » CMP» » R1, R5
61 » BNE» » failp1
62 »·······
63 » MOVW» R2, (R0)»·······
64 » MOVW» R3, (R4)» // release mutex
65 » MOVW» $1, R0
66 » RET
67 failp1:»
68 » MOVW» R3, (R4)» // release mutex
69 failp0:
70 » MOVW» $0, R0
71 » RET
72
42 DATA runtime·cas_mutex(SB)/4, $0 73 DATA runtime·cas_mutex(SB)/4, $0
43 GLOBL runtime·cas_mutex(SB), $4 74 GLOBL runtime·cas_mutex(SB), $4
OLDNEW
« no previous file with comments | « no previous file | src/pkg/runtime/arm/cas6.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b