Changeset 28135 in webkit for trunk/JavaScriptCore/wtf/TCSpinLock.h
- Timestamp:
- Nov 29, 2007, 12:46:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/TCSpinLock.h
r27709 r28135 1 // Copyright (c) 2005, Google Inc.1 // Copyright (c) 2005, 2006, Google Inc. 2 2 // All rights reserved. 3 3 // … … 58 58 // The following is a struct so that it can be initialized at compile time 59 59 struct TCMalloc_SpinLock { 60 volatile unsigned int private_lockword_; 61 62 inline void Init() { private_lockword_ = 0; } 63 inline void Finalize() { } 64 60 65 61 inline void Lock() { 66 62 int r; … … 69 65 __asm__ __volatile__ 70 66 ("xchgl %0, %1" 71 : "=r"(r), "=m"( private_lockword_)72 : "0"(1), "m"( private_lockword_)73 : "memory"); 74 #else 75 volatile unsigned int *lockword_ptr = & private_lockword_;67 : "=r"(r), "=m"(lockword_) 68 : "0"(1), "m"(lockword_) 69 : "memory"); 70 #else 71 volatile unsigned int *lockword_ptr = &lockword_; 76 72 __asm__ __volatile__ 77 73 ("1: lwarx %0, 0, %1\n\t" … … 85 81 #elif COMPILER(MSVC) 86 82 __asm { 87 mov eax, this ; store & private_lockword_ (which is this+0) in eax83 mov eax, this ; store &lockword_ (which is this+0) in eax 88 84 mov ebx, 1 ; store 1 in ebx 89 xchg [eax], ebx ; exchange private_lockword_ and 190 mov r, ebx ; store old value of private_lockword_ in r91 } 92 #endif 93 if (r) TCMalloc_SlowLock(& private_lockword_);85 xchg [eax], ebx ; exchange lockword_ and 1 86 mov r, ebx ; store old value of lockword_ in r 87 } 88 #endif 89 if (r) TCMalloc_SlowLock(&lockword_); 94 90 } 95 91 … … 99 95 __asm__ __volatile__ 100 96 ("movl $0, %0" 101 : "=m"( private_lockword_)102 : "m" ( private_lockword_)97 : "=m"(lockword_) 98 : "m" (lockword_) 103 99 : "memory"); 104 100 #else … … 107 103 "eieio\n\t" 108 104 "stw %1, %0" 109 : "=o" ( private_lockword_)105 : "=o" (lockword_) 110 106 : "r" (0) 111 107 : "memory"); … … 113 109 #elif COMPILER(MSVC) 114 110 __asm { 115 mov eax, this ; store & private_lockword_ (which is this+0) in eax116 mov [eax], 0 ; set private_lockword_ to 0111 mov eax, this ; store &lockword_ (which is this+0) in eax 112 mov [eax], 0 ; set lockword_ to 0 117 113 } 118 114 #endif 119 115 } 120 121 #ifdef WTF_CHANGES 122 inline bool IsLocked() { 123 return private_lockword_ != 0; 124 } 125 #endif 116 // Report if we think the lock can be held by this thread. 117 // When the lock is truly held by the invoking thread 118 // we will always return true. 119 // Indended to be used as CHECK(lock.IsHeld()); 120 inline bool IsHeld() const { 121 return lockword_ != 0; 122 } 123 124 volatile unsigned int lockword_; 126 125 }; 127 126
Note:
See TracChangeset
for help on using the changeset viewer.