Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: src/futex-emulation.h

Issue 2659083004: [SAB] Fix crash in Atomics.wake w/ infinite count. (Closed)
Patch Set: fix Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/futex-emulation.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_FUTEX_EMULATION_H_ 5 #ifndef V8_FUTEX_EMULATION_H_
6 #define V8_FUTEX_EMULATION_H_ 6 #define V8_FUTEX_EMULATION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 FutexWaitListNode* head_; 76 FutexWaitListNode* head_;
77 FutexWaitListNode* tail_; 77 FutexWaitListNode* tail_;
78 78
79 DISALLOW_COPY_AND_ASSIGN(FutexWaitList); 79 DISALLOW_COPY_AND_ASSIGN(FutexWaitList);
80 }; 80 };
81 81
82 82
83 class FutexEmulation : public AllStatic { 83 class FutexEmulation : public AllStatic {
84 public: 84 public:
85 // Pass to Wake() to wake all waiters.
86 static const uint32_t kWakeAll = UINT32_MAX;
87
85 // Check that array_buffer[addr] == value, and return "not-equal" if not. If 88 // Check that array_buffer[addr] == value, and return "not-equal" if not. If
86 // they are equal, block execution on |isolate|'s thread until woken via 89 // they are equal, block execution on |isolate|'s thread until woken via
87 // |Wake|, or when the time given in |rel_timeout_ms| elapses. Note that 90 // |Wake|, or when the time given in |rel_timeout_ms| elapses. Note that
88 // |rel_timeout_ms| can be Infinity. 91 // |rel_timeout_ms| can be Infinity.
89 // If woken, return "ok", otherwise return "timed-out". The initial check and 92 // If woken, return "ok", otherwise return "timed-out". The initial check and
90 // the decision to wait happen atomically. 93 // the decision to wait happen atomically.
91 static Object* Wait(Isolate* isolate, Handle<JSArrayBuffer> array_buffer, 94 static Object* Wait(Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
92 size_t addr, int32_t value, double rel_timeout_ms); 95 size_t addr, int32_t value, double rel_timeout_ms);
93 96
94 // Wake |num_waiters_to_wake| threads that are waiting on the given |addr|. 97 // Wake |num_waiters_to_wake| threads that are waiting on the given |addr|.
95 // The rest of the waiters will continue to wait. The return value is the 98 // |num_waiters_to_wake| can be kWakeAll, in which case all waiters are
96 // number of woken waiters. 99 // woken. The rest of the waiters will continue to wait. The return value is
100 // the number of woken waiters.
97 static Object* Wake(Isolate* isolate, Handle<JSArrayBuffer> array_buffer, 101 static Object* Wake(Isolate* isolate, Handle<JSArrayBuffer> array_buffer,
98 size_t addr, int num_waiters_to_wake); 102 size_t addr, uint32_t num_waiters_to_wake);
99 103
100 // Return the number of threads waiting on |addr|. Should only be used for 104 // Return the number of threads waiting on |addr|. Should only be used for
101 // testing. 105 // testing.
102 static Object* NumWaitersForTesting(Isolate* isolate, 106 static Object* NumWaitersForTesting(Isolate* isolate,
103 Handle<JSArrayBuffer> array_buffer, 107 Handle<JSArrayBuffer> array_buffer,
104 size_t addr); 108 size_t addr);
105 109
106 private: 110 private:
107 friend class FutexWaitListNode; 111 friend class FutexWaitListNode;
108 112
109 static base::LazyMutex mutex_; 113 static base::LazyMutex mutex_;
110 static base::LazyInstance<FutexWaitList>::type wait_list_; 114 static base::LazyInstance<FutexWaitList>::type wait_list_;
111 }; 115 };
112 } // namespace internal 116 } // namespace internal
113 } // namespace v8 117 } // namespace v8
114 118
115 #endif // V8_FUTEX_EMULATION_H_ 119 #endif // V8_FUTEX_EMULATION_H_
OLDNEW
« no previous file with comments | « no previous file | src/futex-emulation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698