~ubuntu-branches/ubuntu/trusty/nodejs/trusty

« back to all changes in this revision

Viewing changes to deps/v8/src/atomicops_internals_mips_gcc.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#ifndef V8_ATOMICOPS_INTERNALS_MIPS_GCC_H_
31
31
#define V8_ATOMICOPS_INTERNALS_MIPS_GCC_H_
32
32
 
33
 
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("sync" : : : "memory")
 
33
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
34
34
 
35
35
namespace v8 {
36
36
namespace internal {
48
48
inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
49
49
                                         Atomic32 old_value,
50
50
                                         Atomic32 new_value) {
51
 
  Atomic32 prev;
52
 
  __asm__ __volatile__("1:\n"
53
 
                       "ll %0, %1\n"  // prev = *ptr
 
51
  Atomic32 prev, tmp;
 
52
  __asm__ __volatile__(".set push\n"
 
53
                       ".set noreorder\n"
 
54
                       "1:\n"
 
55
                       "ll %0, %5\n"  // prev = *ptr
54
56
                       "bne %0, %3, 2f\n"  // if (prev != old_value) goto 2
55
 
                       "nop\n"  // delay slot nop
56
 
                       "sc %2, %1\n"  // *ptr = new_value (with atomic check)
 
57
                       "move %2, %4\n"  // tmp = new_value
 
58
                       "sc %2, %1\n"  // *ptr = tmp (with atomic check)
57
59
                       "beqz %2, 1b\n"  // start again on atomic error
58
60
                       "nop\n"  // delay slot nop
59
61
                       "2:\n"
60
 
                       : "=&r" (prev), "=m" (*ptr), "+&r" (new_value)
 
62
                       ".set pop\n"
 
63
                       : "=&r" (prev), "=m" (*ptr), "=&r" (tmp)
61
64
                       : "Ir" (old_value), "r" (new_value), "m" (*ptr)
62
65
                       : "memory");
63
66
  return prev;
68
71
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
69
72
                                         Atomic32 new_value) {
70
73
  Atomic32 temp, old;
71
 
  __asm__ __volatile__("1:\n"
 
74
  __asm__ __volatile__(".set push\n"
 
75
                       ".set noreorder\n"
 
76
                       "1:\n"
72
77
                       "ll %1, %2\n"  // old = *ptr
73
78
                       "move %0, %3\n"  // temp = new_value
74
79
                       "sc %0, %2\n"  // *ptr = temp (with atomic check)
75
80
                       "beqz %0, 1b\n"  // start again on atomic error
76
81
                       "nop\n"  // delay slot nop
 
82
                       ".set pop\n"
77
83
                       : "=&r" (temp), "=&r" (old), "=m" (*ptr)
78
84
                       : "r" (new_value), "m" (*ptr)
79
85
                       : "memory");
87
93
                                          Atomic32 increment) {
88
94
  Atomic32 temp, temp2;
89
95
 
90
 
  __asm__ __volatile__("1:\n"
 
96
  __asm__ __volatile__(".set push\n"
 
97
                       ".set noreorder\n"
 
98
                       "1:\n"
91
99
                       "ll %0, %2\n"  // temp = *ptr
92
 
                       "addu %0, %3\n"  // temp = temp + increment
93
 
                       "move %1, %0\n"  // temp2 = temp
94
 
                       "sc %0, %2\n"  // *ptr = temp (with atomic check)
95
 
                       "beqz %0, 1b\n"  // start again on atomic error
96
 
                       "nop\n"  // delay slot nop
 
100
                       "addu %1, %0, %3\n"  // temp2 = temp + increment
 
101
                       "sc %1, %2\n"  // *ptr = temp2 (with atomic check)
 
102
                       "beqz %1, 1b\n"  // start again on atomic error
 
103
                       "addu %1, %0, %3\n"  // temp2 = temp + increment
 
104
                       ".set pop\n"
97
105
                       : "=&r" (temp), "=&r" (temp2), "=m" (*ptr)
98
106
                       : "Ir" (increment), "m" (*ptr)
99
107
                       : "memory");
103
111
 
104
112
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
105
113
                                        Atomic32 increment) {
 
114
  ATOMICOPS_COMPILER_BARRIER();
106
115
  Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);
107
116
  ATOMICOPS_COMPILER_BARRIER();
108
117
  return res;
117
126
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
118
127
                                       Atomic32 old_value,
119
128
                                       Atomic32 new_value) {
120
 
  Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
121
 
  ATOMICOPS_COMPILER_BARRIER();
122
 
  return x;
 
129
  ATOMICOPS_COMPILER_BARRIER();
 
130
  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
 
131
  ATOMICOPS_COMPILER_BARRIER();
 
132
  return res;
123
133
}
124
134
 
125
135
inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
126
136
                                       Atomic32 old_value,
127
137
                                       Atomic32 new_value) {
128
138
  ATOMICOPS_COMPILER_BARRIER();
129
 
  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
 
139
  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
 
140
  ATOMICOPS_COMPILER_BARRIER();
 
141
  return res;
130
142
}
131
143
 
132
144
inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
134
146
}
135
147
 
136
148
inline void MemoryBarrier() {
137
 
  ATOMICOPS_COMPILER_BARRIER();
 
149
  __asm__ __volatile__("sync" : : : "memory");
138
150
}
139
151
 
140
152
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {