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

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

Issue 2225013002: Remove unused isolate parameter from NumberToSize and TryNumberToSize (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « src/conversions-inl.h ('k') | src/heap/array-buffer-tracker-inl.h » ('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 #include "src/futex-emulation.h" 5 #include "src/futex-emulation.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/macros.h" 9 #include "src/base/macros.h"
10 #include "src/base/platform/time.h" 10 #include "src/base/platform/time.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 tail_ = node->prev_; 68 tail_ = node->prev_;
69 } 69 }
70 70
71 node->prev_ = node->next_ = nullptr; 71 node->prev_ = node->next_ = nullptr;
72 } 72 }
73 73
74 74
75 Object* FutexEmulation::Wait(Isolate* isolate, 75 Object* FutexEmulation::Wait(Isolate* isolate,
76 Handle<JSArrayBuffer> array_buffer, size_t addr, 76 Handle<JSArrayBuffer> array_buffer, size_t addr,
77 int32_t value, double rel_timeout_ms) { 77 int32_t value, double rel_timeout_ms) {
78 DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length())); 78 DCHECK(addr < NumberToSize(array_buffer->byte_length()));
79 79
80 void* backing_store = array_buffer->backing_store(); 80 void* backing_store = array_buffer->backing_store();
81 int32_t* p = 81 int32_t* p =
82 reinterpret_cast<int32_t*>(static_cast<int8_t*>(backing_store) + addr); 82 reinterpret_cast<int32_t*>(static_cast<int8_t*>(backing_store) + addr);
83 83
84 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer()); 84 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer());
85 85
86 if (*p != value) { 86 if (*p != value) {
87 return isolate->heap()->not_equal(); 87 return isolate->heap()->not_equal();
88 } 88 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 wait_list_.Pointer()->RemoveNode(node); 184 wait_list_.Pointer()->RemoveNode(node);
185 node->waiting_ = false; 185 node->waiting_ = false;
186 186
187 return result; 187 return result;
188 } 188 }
189 189
190 190
191 Object* FutexEmulation::Wake(Isolate* isolate, 191 Object* FutexEmulation::Wake(Isolate* isolate,
192 Handle<JSArrayBuffer> array_buffer, size_t addr, 192 Handle<JSArrayBuffer> array_buffer, size_t addr,
193 int num_waiters_to_wake) { 193 int num_waiters_to_wake) {
194 DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length())); 194 DCHECK(addr < NumberToSize(array_buffer->byte_length()));
195 195
196 int waiters_woken = 0; 196 int waiters_woken = 0;
197 void* backing_store = array_buffer->backing_store(); 197 void* backing_store = array_buffer->backing_store();
198 198
199 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer()); 199 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer());
200 FutexWaitListNode* node = wait_list_.Pointer()->head_; 200 FutexWaitListNode* node = wait_list_.Pointer()->head_;
201 while (node && num_waiters_to_wake > 0) { 201 while (node && num_waiters_to_wake > 0) {
202 if (backing_store == node->backing_store_ && addr == node->wait_addr_) { 202 if (backing_store == node->backing_store_ && addr == node->wait_addr_) {
203 node->waiting_ = false; 203 node->waiting_ = false;
204 node->cond_.NotifyOne(); 204 node->cond_.NotifyOne();
205 --num_waiters_to_wake; 205 --num_waiters_to_wake;
206 waiters_woken++; 206 waiters_woken++;
207 } 207 }
208 208
209 node = node->next_; 209 node = node->next_;
210 } 210 }
211 211
212 return Smi::FromInt(waiters_woken); 212 return Smi::FromInt(waiters_woken);
213 } 213 }
214 214
215 215
216 Object* FutexEmulation::NumWaitersForTesting(Isolate* isolate, 216 Object* FutexEmulation::NumWaitersForTesting(Isolate* isolate,
217 Handle<JSArrayBuffer> array_buffer, 217 Handle<JSArrayBuffer> array_buffer,
218 size_t addr) { 218 size_t addr) {
219 DCHECK(addr < NumberToSize(isolate, array_buffer->byte_length())); 219 DCHECK(addr < NumberToSize(array_buffer->byte_length()));
220 void* backing_store = array_buffer->backing_store(); 220 void* backing_store = array_buffer->backing_store();
221 221
222 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer()); 222 base::LockGuard<base::Mutex> lock_guard(mutex_.Pointer());
223 223
224 int waiters = 0; 224 int waiters = 0;
225 FutexWaitListNode* node = wait_list_.Pointer()->head_; 225 FutexWaitListNode* node = wait_list_.Pointer()->head_;
226 while (node) { 226 while (node) {
227 if (backing_store == node->backing_store_ && addr == node->wait_addr_ && 227 if (backing_store == node->backing_store_ && addr == node->wait_addr_ &&
228 node->waiting_) { 228 node->waiting_) {
229 waiters++; 229 waiters++;
230 } 230 }
231 231
232 node = node->next_; 232 node = node->next_;
233 } 233 }
234 234
235 return Smi::FromInt(waiters); 235 return Smi::FromInt(waiters);
236 } 236 }
237 237
238 } // namespace internal 238 } // namespace internal
239 } // namespace v8 239 } // namespace v8
OLDNEW
« no previous file with comments | « src/conversions-inl.h ('k') | src/heap/array-buffer-tracker-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698